Entityframework 4.0 .CreateQuery<T> and OrderBy exception
Posted
by Sammy
on Stack Overflow
See other posts from Stack Overflow
or by Sammy
Published on 2010-06-13T20:29:55Z
Indexed on
2010/06/13
20:32 UTC
Read the original article
Hit count: 559
Hi Guys, I thought this was fixed in 4.0 I have this method
public IQueryable<T> All(Expression<Func<T,object>> sort)
{
return EntityContext.CreateQuery<T>(EntityName).AsQueryable<T>().OrderBy(sort);
}
this throws the following exception Unable to cast the type 'System.Int32' to type 'System.Object'. LINQ to Entities only supports casting Entity Data Model primitive types. Source is System.Data.Entity any idea how to fix this or if theres any workaround
© Stack Overflow or respective owner