示例#1
0
 public List <CommonCode2> GetCom2List(string code1)
 {
     using (var db = new ShopDBContext())
     {
         return(db.CommonCode2s.Where(c => c.Com1Code1 == code1).ToList());
     }
 }
示例#2
0
 public List <CommonCode1> GetCom1List()
 {
     using (var db = new ShopDBContext())
     {
         return(db.CommonCode1s.ToList());
     }
 }
示例#3
0
 public void CreateProduct(Product product)
 {
     using (var db = new ShopDBContext())
     {
         var prod = db.Products.Add(product);
         db.SaveChanges();
     }
 }
示例#4
0
 public void DeleteProduct(Product product)
 {
     using (var db = new ShopDBContext())
     {
         var prod = db.Products.FirstOrDefault(u => u.Code == product.Code);
         db.Products.Remove(prod);
         db.SaveChanges();
     }
 }
示例#5
0
 public void UpdateProduct(Product product)
 {
     using (var db = new ShopDBContext())
     {
         var prod = db.Products.FirstOrDefault(u => u.Code == product.Code);
         prod.Description = product.Description;
         prod.Name        = product.Name;
         prod.Price       = product.Price;
         db.SaveChanges();
     }
 }
示例#6
0
 public List <Product> GetProductList()
 {
     using (var db = new ShopDBContext())
     {
         var pro = db.Products
                   .Include(p => p.CommonCode1)
                   .Include(p => p.CommonCode2)
                   .ToList();
         return(pro);
     }
 }