Hi all,
I'm currently trying to convert Eric P's MVC Grid solution (http://
tinyurl.com/lcbwqt) to work with NH. One part of this conversion
requires building up a query to NH to fetch the data for the grid. I'm
not quite sure how to convert the following LINQ expression to a
Criteria expression (I'm somewhat new to NH):
private IQueryable<TEntity> AddQuerySorting(IQueryable<TEntity> query)
{
if (string.IsNullOrEmpty(_sortField))
return query;
//Used approach from
http://www.singingeels.com/Articles/Self_Sorting_GridView_with_LINQ_Expression_Trees.aspx
//instead of a long switch statement
var param = linqExp.Expression.Parameter(typeof(TEntity), typeof
(TEntity).Name);
var sortExpression = linqExp.Expression.Lambda<Func<TEntity,
object>>(
linqExp.Expression.Convert(
linqExp.Expression.Property(param,
_sortField), typeof(object)),
param);
if (_sortDirection == SortDirection.Asc)
query = query.OrderBy(sortExpression);
else
query = query.OrderByDescending(sortExpression);
return query;
}
Can anyone help with converting the sortExpression to work with
Criteria?
I know NH 2.1GA supports NHibernate.Linq 1.0GA, but I'm using S#arp
Architecture 1.0 RTM and have not recompiled and updated to 2.1GA +
Linq 1.0GA, so I need to figure out how to do this conversion.
Thanks for the help,
- Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---