Michiel Cornille
Michiel Cornille

Reputation: 2097

No generic method 'OrderBy' on type 'Queryable' is compatible with the supplied type arguments

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, but it's not working for me. I also 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.

I'm clueless how to diagnose which of the four parameters is incorrect. I'm thinking one of the expression types may be incorrect.

Upvotes: 5

Views: 3089

Answers (1)

Michiel Cornille
Michiel Cornille

Reputation: 2097

My type definitions were wrong, as the error suggested.

typeof(TSource) had to be typeof(TNav), since we are ordering source.Gifts.

Upvotes: 1

Related Questions