Java Mailing List Archive

Home » the NHibernate development list »

[NHibernate-development] NHibernate.Linq and properties

Kim Johansson


Author LoginPost Reply
Hello gurus! I've quite recently discovered NHibernate.Linq, written
some code and it worked perfectly. There's one thing I want to be able
to do, I want to be able to use the IQueryable interface on my
properties on my entities. How would you do that? I'm thinking about
creating a class implementing IQueryable and ICollection, that takes an
ISession and runs queries in that. I want to make the properties more
lazy loaded than they are by default in NHibernate. So I can do
something like this:

IUser user = this.UserService.GetUserById(1);
IEnumerable<IMessage> messages = user.Messages.Where(m =>

foreach(IMessage message in messages)

And that query will only get 10 messages from the database.

How would you do this?

Thanks in advance, Kim Johansson

Nhibernate-development mailing list
©2008 - Jax Systems, LLC, U.S.A.