I am trying to use system.dynamic.linq to create dynamic sorting.
this, is the query that I use:
var query = dalSession.Query<T>().AsQueryable(); var res = (from x in query orderby "x.FirstName" select x)
this is the mysql output:
select affiliate0_.id as id0_, affiliate0_.first_name as first6_0_, from affiliate affiliate0_ order by 'x.FirstName' //FirstName as well
So you can see that the output went to the mysql query is the direct string, and not its reflection, (
'x.FirstName') or (
This has no meaning in mysql context, it looks like I need order by
Is there anyway to provide the Nhibernate the member itself? So the compiled query will be done normally?
var param = Expression.Parameter("x"); var prop = Expression.Property(param, "FirstName"); var lambda = Expression.Lambda<Func<User, string>>(prop, param); query.Orderby(lambda);