NHibernate.Linq and properties

Kim Johansson <[email protected]> Wed, 01 Apr 2009 23:45:07 +0200
Newsgroups gmane.comp.windows.dotnet.nhibernate.devel
Message-ID <[email protected]>
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 => 
m.IsActive).Skip(offset).Take(10);

foreach(IMessage message in messages)
 Console.WriteLine(message);

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

How would you do this?

Thanks in advance, Kim Johansson

------------------------------------------------------------------------------