O'Reilly logo

NHibernate 3 Beginner's Guide by Gabriel N. Schenker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using LINQ to NHibernate the wrong way

LINQ to NHibernate is a really nice addition to the framework and makes querying the database much easier and more enjoyable. The queries are also much more readable than the same queries written in HQL, Criteria Query, or QueryOver syntax. Also, LINQ queries are composable in the same way we used from LINQ to objects.

However, there also lies the danger of this API if not used carefully. To fully leverage LINQ we have to understand the system boundaries.

As long as we stay in the context of LINQ to NHibernate, we are dealing with sets of results of type IQueryable<T> where T is the placeholder for the entity we are querying, for example, Product or Order.

LINQ queries are always executed by lazy loading. That ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required