I am using EntityFrameworkCore 3.1.11 and having below query
var list = _context.Table1
.Include(i => i.ListofGroupIds)
.Where(i =>
i.ListofGroupIds.Select(x => x.GroupId).Any(m =>
SelectedIds.Where(z => z.CreatedDate <= i.SentDate).Select(y => y.Id).Contains(m)
))
);
Here i need to check whether any of the item(Id) present in SelectedIds(list having properties like {Id,CreatedDate and other fields}) is a part of ListOfGroupIds, According to this i need to fetch the rows. But i am getting run time exception as
The Query (LINQ) expression could not be Translated Entity Framework Core,Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
I checked different post related to this and even tried enter link description here
I got only one solution which is working is by adding AsEnumerable to the query.But i dont want it to be AsEnumerable because i am dealing with huge data, and i can't split the contains query seprate because i need to check one condition(i.SentDate) inside that ANY.
So if there is any way to do this in a single query without making AsEnumerable.
Assuming this is the structure you have (I'm ignoring all the foreign keys you may have on purpose, this is just an example!)
You can rewrite your query as
Or, if possible, simply join the two tables needed
Or