I have Database Table with a composite primary key, so want to check if both key pairs are matching
public async Task<IList<AccountingAccountCategoryMap>> GetList(IEnumerable<AccountingAccountCategoryKey> keys)
{
return await Query.Where(item => keys.Any(x =>
x.CategoryId == item.CategoryId && x.AccountingAccountId ==
item.AccountingAccountId)).ToListAsync();
}
I get this error:
{ "Message": "The LINQ expression 'x => x.CategoryId == EntityShaperExpression: \r\n
Orderlyze.Service.DL.Contract.Entity.AccountingAccountCategoryMap\r\n ValueBufferExpression: \r\n ProjectionBindingExpression: EmptyProjectionMember\r\n IsNullable: False\r\n.CategoryId && x.AccountingAccountId == EntityShaperExpression: \r\n
Orderlyze.Service.DL.Contract.Entity.AccountingAccountCategoryMap\r\n ValueBufferExpression: \r\n ProjectionBindingExpression: EmptyProjectionMember\r\n IsNullable: False\r\n.AccountingAccountId' 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'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.", "Inner": "" }
The Question is why does work? And is there way to fix it without Client Evaluation?