public List <Category> Categories()
 {
     using (var context = new NorthwindSlimEntities())
     {
         var categories = context.Categories.OrderBy(a => a.CategoryId).ToList();
         return(categories);
     }
 }
示例#2
0
 public List <Product> GatProductByCategoriesId(int categoryId)
 {
     using (var context = new NorthwindSlimEntities())
     {
         var products = (from p in context.Products
                         where p.CategoryId == categoryId
                         orderby p.ProductName
                         select p).ToList();
         return(products);
     }
 }