I'm writing some code that will modify an expression so that the subquery contained in it will get ordered.
I found a similar piece of code here on SO: https://stackoverflow.com/a/1379693/509464 But it's not working for me Also I tried looking at this answer, but i'm not able to apply this to my piece of code
No generic method 'OrderBy' on type 'Queryable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.
MethodCallExpression orderByCallExpression = Expression.Call(
typeof(Queryable),
"OrderBy"/*Descending*/,
new Type[] { typeof(TSource), filterpart.OrderOverPropertyGetterValueType},
navigationalProperty.Body,
filterpart.OrderOverPropertyGetter);
I'm trying to figure out which of the 2 type parameters or 2 other arguments is causing this error.
- OrderOverPropertyGetterValueType is just
typeof(DateTime)
in this case - TSource is an Entity Type (Gifts)
- navigationalProperty.Body contains {
source.Gifts.AsQueryable()
} with expression type:System.Linq.Expressions.MethodCallExpression
- filterpart.OrderOverPropertyGetter contains
{g => g.Date}
with expression typeSystem.Linq.Expressions.Expression<System.Func<Gift,System.DateTime>>
I'm clueless as how to diagnose wich of the four parameters is incorrect, i'm thinking one of the expression types may be incorrect...