Skip to content
Discussion options

You must be logged in to vote

with OfType but it transforms the expression in object, for example with a class with Id as int, x => x.Id becomes x => Convert(x.Id, Object) and when the expression is evaluated from entity framework, for example with MaxAsync method it explodes because EF integration can retrieve a Task of int instead of a Task of object,

I'd say the problem is that you are missing the Convert. If I add the following line to your Select<TSource>, then the test will pass for me (using an InMemory database):

selector = Expression.Lambda(
    Expression.Convert(selector.Body, typeof(object)),
    selector.Parameters);

(Also note that I had issues compiling your code, because of the use of Windows 1252 in…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@KeyserDSoze
Comment options

@CyrusNajmabadi
Comment options

@svick
Comment options

svick Aug 18, 2022
Collaborator

Answer selected by KeyserDSoze
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants