Open JackPSmith opened 1 year ago
Just a first impression: .AsQueryable().AsEnumerable()
looks suspicious. Generally EF Core is only able to translate Expression
-stuff, as used by the IQueryable
-methods; IEnumerable
on the other hand uses compiled Func
s, that aren't easily translated. Can you remove .AsQueryable().AsEnumerable()
and see, if it changes anything? If the compiler objects, try removing only .AsEnumerable()
or explicitly casting the lambda inside the Select
to Expression<Func<..., Address>>
(replacing ...
by the type of items in AddressList
).
I still receive the same error after removing .AsQueryable().AsEnumberable()
and also removing just .AsEnumerable()
However, for your suggestion of explicitly casting the lambda expression, could you elaborate a little more as I'm afraid I'm not following you. In my case it would be Expression<Func<AddressData,Address>>
Hey Guys,
I have an issue with mapping an EF Core 7 Json column into an class. I am presented with the following exception.
System.InvalidOperationException: The LINQ expression 'JsonQueryExpression(p.Addresses, $.AddressList)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'.
The code below is the projection that is mapping the queried
AddressesData
class to theAddresses
class. (Which theAddresses
is an EF Core 7 Json column, see DBContext at the bottom)Below is the method that contains the EF Query
However, as you can see in the above code, I'm also using a projection for
Privacy
which I've converted back to an original Relational Database format with a table instead of Json column to test this issue, and this works without any issues.I was just wondering if there's currently no support for EF Core 7 Json columns?
Below is the
AddressesData
database model class & theAddresses
it is being mapped into.And here's the EF Db context config too
Thanks in advance!