Reputation: 6431
I am trying to fetch entities by their id properties. I know i can fetch them one by one but i think best way to fetch would be in single call. So how can i do that in below sample?
internal List<Product> GetProducts(int[] productIds)
{
IQueryable<Product> query = ctx.Products;
//how to fetch ?
return query.ToList();
}
Upvotes: 1
Views: 49
Reputation: 176886
are you looking for this :-
var product = from p in Products
where productid.Contains(p.Id)
select p;
Upvotes: 1
Reputation: 39491
internal List<Product> GetProducts(int[] productIds)
{
IQueryable<Product> query = ctx.Products.Where(product => productIds.Contains(product.ID));
return query.ToList();
}
Upvotes: 2