tags:

views:

46

answers:

3

Is it possible to mimic IQueryable with NHibernate?

I was looking at Nhibernate docs and for what i could tell, it always returns a List of objects, that have it's attributes indexed by a integer. Ok, perfect, that works.

But is there a way to retrieve objects like LINQ? With something like IQueryable?

Thanks

A: 

There is a linq provider for NHibernate.... not perfect, but handles most stuff

Keith Nicholas
+1  A: 

Linq to NHibernate is available as part of NHibernate Contrib: http://sourceforge.net/projects/nhcontrib/files/

I have found that it is only usuable for simple queries.

cbp
+3  A: 

As other pointed out, there's a Linq provider for NHibernate 2.x which, while limited, handles simple queries (internally, it translates them to Criteria)

This is the correct download URL: http://sourceforge.net/projects/nhibernate/files/NHibernate/2.1.2GA/NHibernate.Linq-2.1.2-GA-Bin.zip/download

The next version of NHibernate, 3.x (currently in development) has a built-in Linq provider, which is much more powerful, handling more complex queries including projections of several types.

You can download the binaries from here, or compile from the trunk. It's pretty stable already.

Diego Mijelshon
Thank you all very much for you thoughts.So I think it's a safe bet to use this provider to handle simple stuff. And later on i wont have to migrate code.Thanks to all
George