views:

62

answers:

2

I want to let my users create specifications to be executed in a nhibernate.Linq query.

Is it possible? I ask the user to write a query string (HQL I suppose) so it will be serializable and in a combobox the user can apply it to current results

+1  A: 

Linq expressions are not serializable.

HQL, on the other hand, is just a string like SQL, so that would work.

But you have to really trust your user, as there is nothing stopping him from typing "DELETE TheMostImportantEntity WHERE 1=1".

Diego Mijelshon
Yes, it's true.Another problem is that user doesn't know the exact class properties name so it's not so easy to create query expression.I'll go with a combobox of precompiled Specifications to choose between, for the moment.
Mauro Destro
A: 

One other option may be using the LINQ Dynamic Query Library (see details here: http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx )

DanP