Using the below code, I'm Attempting to get a list of items which is in price range by Linq
public Task<List<Item>> GetFilteredItems(List<Tuple<decimal, decimal>> priceList)
{
var itemList = from i in _dbTable
where (priceList.Count() == 0 || (priceList.All(x => i.MRP >= x.Item1) && priceList.All(x => i.MRP <= x.Item2)))
select i;
return Task.FromResult(itemList.Cast<Item>().ToList());
}
But Getting an error
Error creating query string: The LINQ expression 'x => EntityShaperExpression:
GiftCartBO.Entities.ItemTBL
ValueBufferExpression:
ProjectionBindingExpression: EmptyProjectionMember
IsNullable: False
.MRP >= x.Item1' 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..