Hi. I just saw the post on StackOverflow, but it is incomplete, there isn't a full example of the concept.
Can you try my "Domain package" on Nuget and see how to write the missing FetchXxx methods? I would also have a unique method called Include like Entity Framework, to simplify the client code. Thanks, Matteo. On Wednesday, August 15, 2012 8:50:41 PM UTC+2, Randy Burden wrote: > > Hi. Take a look at the following StackOverflow post below. At my job, we > are currently using a slightly modified version of the referenced post to > wrap NHibernate's .Fetch() methods. Our organization has moved away from > direct ISession usage to an IRepository<T> with great success. > > StackOverflow post: http://stackoverflow.com/a/5742158/670028 > > As a side note, I really don't get the people bashing the concept of > abstracting away the ISession. Who cares about the switching ORMs argument. > I like the benefit that developers can simply have an IRepository<T> > injected into the constructor of their classes and just use standard LINQ > to do what they need to do to get the job done. Behind the IRepository<T>, > you can implement whatever you want such as your own custom Unit of Work > that makes sense for what your organization and application consider a unit > of work. I'm not advocating that there is no need for direct access to the > ISession at certain times but making it standard practice to use an > IRepository<T> dramatically normalizes how queries look across the > organization. > > When people are allowed to use the ISession freely, you end up with all of > NHibernate's various query APIs spread all over your code base with HQL, > Critieria API, and QueryOver all jumbled up. Show a newcomer to the > organization all of that craziness and they can feel overwhelmed. Or show > them a standard IRepository<T> query where they are just using standard > LINQ to query over an IQueryable<T> and it makes much more sense with > almost no learning curve and the best part is that they can just get done > quicker without all the ramp up of learning a new API ( or 3 APIs ) for > data access. > > All I'm saying is that there are legit reasons to wrap up the ISession and > abstract away NHibernate internals. I can attest that it can be done and is > being done successfully in an enterprise environment. > > > On Monday, August 13, 2012 2:52:05 PM UTC-5, Matteo Migliore wrote: >> >> Hi! >> >> I wrapped the ISession interface to an IRepository<T> (in a little more >> complex way), now I've the problem to expose the eager loading feature >> so I want to have this: >> IRepository<T> : IEagerLoading<T> >> ... >> >> IEagerLoading<T> : IQueryable<T> >> { >> IEagerLoading<T> Include<TRelated>(Expression<Func<T, TRelated>> >> path); >> } >> >> On the IRepository<T> I want to write customerRepository.Include(x => >> x.Addresses).Include(x => x.MainAddress); >> >> Do you know a simple way to do that? >> >> Thanks, >> Matteo. >> > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/Ef3ELr15DEsJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
