我有 Product 实体并在存储库类中编写一个方法(使用 npgsql)。但我收到错误:
无法翻译。以可翻译的形式重写查询,或者通过插入对“AsEnumerable”、“AsAsyncEnumerable”、“ToList”或“ToListAsync”的调用来显式切换到客户端计算。有关详细信息,请参阅https://go.microsoft.com/fwlink/?linkid=2101038 。System.InvalidOperationException:LINQ 表达式的 => s.ProductId == EntityShaperExpression:
public class Product:IEntity
{
public string Id { get; set; }
public string SerialNo { get; set; }
public string Imei { get; set; }
public string Name { get; set; }
}
public class ProductInput
{
public string ProductId { get; set; }
public string SerialNo { get; set; }
public string Imei { get; set; }
}
public async Task<List<Product>> GetProducts(List<ProductInput> input) //EfCoreProductRepository.cs
{
var result = (from product in (await GetDbContextAsync()).Products
where input.Any(s => s.ProductId == product.Id && s.SerialNo == product.SerialNo && s.Imei == product.Imei)
select product).ToList();
return result;
}
我应该如何编辑查询以避免出现此错误?