ironcev / Pragmatic

[The description is yet to come]
5 stars 3 forks source link

OrderBy value type exception #17

Closed hudo closed 9 years ago

hudo commented 9 years ago

When using OrderBy with value type, exception is thrown, for example:

System.NotSupportedException : Unable to cast the type 'System.Int32' to type 'System.Object'. LINQ to Entities only supports casting EDM primitive or enumeration types.

I think this happens because OrderBy accepts Func<T, object>, which means expression with int param is boxed into an object. In case of using string property for soring, it works fine.

Maybe we should change OrderBy signature to OrderBy(Expression<Func<T,R>> criteria,...) ?

ironcev commented 9 years ago

Hi hudo, Thanks for reporting the issue. It is fixed now. The NuGet package with the fix is available as well, under the package version 0.7.0.1.