views:

446

answers:

2

I understand that a IQueryable cannot be serialized. That means that queries can not be serialized, sent to a webservice, deserialized, queried and then sent back.

I was wondering if it is possible to convert a hibernate linq query to hql to be sent over the wire.

Is there another route I am missing?

A: 

I think I've seen ADO.NET Data Services as advertised to work with NHibernate:

http://wildermuth.com/2008/07/20/Silverlight_2_NHibernate_LINQ_==_Sweet

http://ayende.com/Blog/archive/2008/07/21/ADO.Net-Data-Services-with-NHibernate.aspx

This is an old post, and not sure how maintained this feature is, but its worth a shot.

eyston
A: 

Hi Paul.

I have a suggestion to you. Do not try to serialize query. Rather provide your user with an ability to compose arbitrary LINQ expression. Then send the expression over the wire (there is a gotcha here, since expressions are not serializable) to your server.

I have recently submitted to NHibernate.Linq project a change to their NHibernateExtensions class - a new ISession extension method List, which accepts an expression and fills the given list with the respective data, much like ICriteria.List method. The change was accepted (see here) so downloading the recent version of NHibernate.Linq should contain this method.

Anyway, you can find the details of this approach here.

mark