This is the same dilemma we found ourselves in when we implemented eager fetching for re-store (re-motion's ORM). We went with Tuna's third option of a second select (neither N+1 nor endlessly wide selects seemed too attractive to us, and we don't have fetch strategies in our mappings, or batching).
The good news is that we implemented all of it in re-linq, only the FetchOne and FetchMany extension methods are in re-store (so any re- linq based provider can decide to use our fetch syntax and strategy, their own or a mix of it). So if you want to look at that third option, I guess you're almost there. Here's the re-store facade: https://svn.re-motion.org/svn/Remotion/trunk/Remotion/Data/DomainObjects/Linq/EagerFetchingExtensionMethods.cs And here's the re-linq meat: https://svn.re-motion.org/svn/Remotion/trunk/Remotion/Data/Linq/EagerFetching The basic idea is to transform this: (from o in orders where ... select o).FetchMany (o => o.OrderItems) into the following two queries: from o in orders where ... select o from o in orders where ... from od in o.OrderItems select od (plus an additional query for each ThenFetchMany/One call) It all happens in the QueryModel, so if your provider can handle those queries individually, there's not much more to do really. If it doesn't quite work out for this scenario, I guess you should have little trouble tweaking it for what you need. However, I can't be bothered to look into it any further since I'm in vacation mode for the next two weeks :-) Hope this helps, Stefan (just arrived at the beautiful Gulf of Naples) On Sep 4, 8:52 pm, Tuna Toksoz <[email protected]> wrote: > You're both mad. > > Tuna Toksöz > Eternal sunshine of the open source mind. > > http://devlicio.us/blogs/tuna_toksozhttp://tunatoksoz.comhttp://twitter.com/tehlike > > > > On Fri, Sep 4, 2009 at 9:51 PM, Steve Strong <[email protected]> wrote: > > That was exactly my plan. Good to know that I'm not going mad :) > > > On 4 Sep 2009, at 20:39, Fabio Maulo wrote: > > > 2009/9/4 Fabio Maulo <[email protected]> > > >> select o.id, l, o.Freight from Order o join fetch o.Lines l where > >> l.Discount > 0 > >> Then, it should need a client side part > > > The client side part should be a new special ResultTrasformer > > -- > > Fabio Maulo- Hide quoted text - > > - Show quoted text -
