I've searched through the forums for a definitive answer on this, but I couldn't find anything that seemed to fit.
I have a table that references itself in a parent-child fashion to form a tree. That table also has a foreign-key to other tables that make up essential data for each node in the tree, and so lazyloading doesn't really make sense.
The tables won't be that big, and it would be OK to load every row of each table in a single query, for two total queries. Even if it was necessary to filter this load at some point, I am using SQL 2005 so I would just use a recursive query.
So, what I want, is a way to have the LLBLGen object graph built based on a single query that returns every object that will be in the graph as a single result set. Does this exist?
I am aware of the prefetch paths. However, I believe that they will execute a query per node, to get the all of the direct children for that particular node only. This could result in many queries for a deep and narrow tree.
The direction I am trying so far is to use Context. My first attempt was to load the Context with each of the collections that contain all the objects I'll need. I was then hoping\assuming that the lazyload when I reference the n:1 object property would see that its already in the Context and not go to the database. Instead it first goes to the database, and then if its in the Context uses that instead. This defeats the purpose.
So at this moment, what I am considering doing, is editing the EntityInclude template to have the GetSingle<[MappedFieldNameRelation]> function first look to see if its in Context, and only if its not there go to the database.
After all of that, I have two questions:
1) Is there already a builtin way to do what I want?
2) If not, and this Context route is my best option, would it make sense to add as an option to LLBLGen the ability to check Context first on a lazyload instead of always going to the db?
Thanks,
Brian