I am using EF 4 but it is giving me error when I try to order my list.
Unable to cast the type 'System.String' to type 'System.Object'. LINQ to Entities only supports casting Entity Data Model primitive types.
This is my code to get the experssion by entering the property name, example below get the Customer Name
var param = Expression.Parameter(typeof(Customer), "N");
var sortExpression = Expression.Lambda<Func<T, object>>
(Expression.Convert(Expression.Property(param, "Name"), typeof(object)), param);
And my EF code is
GetObjectSet<T>().AsQueryable().OrderBy(sortExpression).Skip(0).Take(5);
I know it is some sort of casting problem with EF because it works without the EF but it gives me this error when i hook it up with EF. Is there a work around or something because i don't want to use LINQ.