Method avec list et linq to sql
Bonjour.
j'ai des difficultes avec la methode List. comment ramener la valeur List.
je comprend pas bien.
je vous donne mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
public class northwindService : InorthwindService
{
northwindEntities db = new northwindEntities();
public List<MonProduct> GetAllProductByCathegorie()
{
var ListProduct = from p in db.Products
where p.Category.CategoryID == p.CategoryID
select new MonProduct
{
ProduitId =p.ProductID,
ProduiName= p.ProductName
};
return ListProduct.ToList();
}
}
class MonProduct
{
public int ProduitId { get; set; }
public string ProduiName { get; set; }
} |
je sais bien utilise les autres methode public string/int/bool qui te ramene (return valeur string/int ot bool).
Mais j'ai des difficulte avec List surtout avec linq to sql.
je sais meme pas comment je vais appeler ma methode GetAllProductByCathegorie dans mon code.
j'ai besoin d'explication ou d'un tutorial pour sa merci.
Cordialement
solaar
Ma methode ne ramene aucune valeur.
Bonjour .
je comprend plus rien de ma method.
je une table Departement avec "region" comme cle secondaire.
je fait un trie sur le libelle department;
Code:
1 2 3 4 5 6 7
|
public static IEnumerable<DEPARTEMENT> GetDepartementQuery(string dept , DomainContext _db)
{
return (from q in _db.DEPARTEMENTs where q.LIBELLE_DEPT == dept select q).ToList();
} |
il ne me ramene aucune valeur.... je sais vraiment pas. .... je travail avec DomaineService.
Merci pour l'aide