示例#1
0
 private void CreateProducts(JinShopContext context)
 {
     if (context.Products.Count() == 0)
     {
         var listProduct = new List <Product>()
         {
             new Product()
             {
                 Name        = "A1",
                 Description = "aaa"
             },
             new Product()
             {
                 Name        = "1B",
                 Description = "aaa"
             },
             new Product()
             {
                 Name        = "C1",
                 Description = "aaa"
             },
         };
         context.Products.AddRange(listProduct);
         context.SaveChanges();
     }
 }
示例#2
0
 public void Add(TEntity entity)
 {
     _dbSet.Add(entity);
     _context.SaveChanges();
 }
示例#3
0
 public void Create(Product product)
 {
     _dbSet.Add(product);
     _context.SaveChanges();
 }