Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm working on a new Umbraco project with a external database and I love it. But I've run into a problem and question now I have a query with more then 4 joins now.
Before I worked with the following line (and it works great!)
db.Query<Entity1, Entity2, Entity3, Entity4, Entity1>(new Relator().MapIt, sql).SingleOrDefault();
But now I have to join more tables.
I found the following method
public IEnumerable<TRet> Query<TRet>(Type types, object cb, string sql, params object args)
But I can't get it to work! I don't know how to pass the relator callback into the method.
Our help would be greatly appreciated, Thanks Stefan
This was posted a while ago but did you ever find a solution? I'm encountering the exact same problem. Need to use a Realator with more than the standard 4 joins (just 1 more, not asking for much ;) ).
Would love to hear what you came up with for a solution.
Go modify the source? :)
But can't you just pass in an SQL query as a string, with as many joins as you need, so long as it maps to your return model?
Hi Dan, thanks for the response. I'm trying to avoid modifying the source if possible just to keep the project easier to update and maintain.
I'm retrieving a list of objects that have have List
Am I missing something?
Sample of my code (generic), just want to be able to add SubObj5.
How you would do the above with just a query string? If it was a single model and that model made up of single models I get it, but when you have to use a Relator to iterate and map to a list of sub models, how would that work?
I guess I was being a bit flippant saying modify the source, but originally peta poco was meant to be a simple class that could be modified. So you could take the entire class, move it to your own project, and modify it that way without touching the Umbraco core. Though it's probably not that simple anymore. Guess some kind of extension method wouldn't work?
I can see now what you are trying to do and you are right, there isn't a simple way - I was thinking you just wanted to perform multiple joins that mapped to a single object.
I think where my knowledge comes up short is at the "extension method" part and how to implement that. I'd love to be able to extend Umbrabo.Core.Persistence where the PetaPoco code lives so that I can easily keep my Umbraco core up to date and not have to worry about merging source every time.
If you have any suggestions to point me in the right direction there would be greatly appreciated.
Sitting here and having the same problem. Unfortunately i could not find any solutions too.
i found a suggestion here
but could not turn it into usable code. Hope that some experienced community member can help us.
i dont really want to modifying the source code but changing it by copying would be a possibility
i already tried some nested joins to create a result table to merge multiple tables as one result but without any success.
ps: default" joins and automapping with petapoco works without any issues
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted