Order a List by a arbitrary sort expression?


Problem:

 The type arguments for method 'System.Linq.Queryable.OrderBy<TSource,TKey>(System.Linq.IQueryable<TSource>, System.Linq.Expressions.Expression<System.Func<TSource,TKey>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.



Solution:

Note: This requires reference to: Dynamic.dll (not System.Dynamic.dll) as well as
using System.Linq.Dynamic;
If you don't reference Dynamic.dll, or don't declare the using directive, you'll get an error on AsQueryable().

Post a Comment

0 Comments