Did you already find the "WhereBulkContains" extension: https://entityframework-extensions.net/where-bulk-contains?
IQueriable.Contains how to fix the problem when my collection clearly includes an extremely large number of values
Andrej
221
Reputation points
I have query which me need filtering entries, I use IQueriable.Contains(see ex. below). And when my collection clearly includes an extremely large number of values, I get an error: "Error 8623: The query processor ran out of internal resources and could not produce a query plan.".
Code:
public async Task<IEnumerable<MyModel>> MyMethod(IEnumerable<int> ids, CancellationToken cancellation)
{
//ids.Count > 10000
var foldersQuery = from folder in _dbSet
where ids.Contains(folder.Id)
select folder;
return await foldersQuery.ToListAsync(cancellation);
}
It converts to sql query
select * from Table where Id IN (1, ... 99999)
Could you please me fix this issue, or what can replace it.