Je vai essayer de répondre même si je ne asis pas ce que tu veux, tu veux que ta méthode retourne autre chose que List?
tu peux retourner un IQueryable<MonProduct>.
Et pourquoi tu utilises une autre classe ? (MonProduct)
tu peux directement retourner un IQueryable<Product> sans passer par ta classe MonProduct.
Autre chose, ton critère
where p.Category.CategoryID == p.CategoryID
ne sert à rien car il n'y a aucun filtre, ton critère tu dois le passer en paramètre:
ta méthode devient :
1 2 3 4 5 6 7 8
| public IQueryable<Product> GetAllProductByCathegorie(int categoryID)
{
return from p in db.Products
where p.CategoryID == categoryID
select p;
} |
Partager