コード例 #1
0
        private static void AddTestData(EnityFramWorkDbContext context)
        {
            IList <Product> products = new List <Product>();

            products.Add(new Product {
                Id = 1, Name = "Water Glass", Price = 10.00M, Photo = "", Desciption = "Water Glass for drinking"
            });
            products.Add(new Product {
                Id = 2, Name = "Jug Water Glass", Price = 12.00M, Photo = "", Desciption = "Water Glass for drinking"
            });
            products.Add(new Product {
                Id = 3, Name = "Green Water Glass", Price = 13.00M, Photo = "", Desciption = "Water Glass for drinking"
            });
            products.Add(new Product {
                Id = 4, Name = "Red Water Glass", Price = 14.00M, Photo = "", Desciption = "Water Glass for drinking"
            });
            products.Add(new Product {
                Id = 5, Name = "Yellow Water Glass", Price = 15.00M, Photo = "", Desciption = "Water Glass for drinking"
            });
            context.Products.AddRange(products);

            IList <BasketItem> basketItems = new List <BasketItem>();

            basketItems.Add(new BasketItem {
                Id = 1, ProductId = 1, Quantity = 2, UserId = 1
            });
            basketItems.Add(new BasketItem {
                Id = 2, ProductId = 5, Quantity = 1, UserId = 1
            });
            context.BasketItems.AddRange(basketItems);

            context.SaveChanges();
        }
コード例 #2
0
 public EntityFrameworkRepository(EnityFramWorkDbContext context) : base(context)
 {
     _context = context;
 }
コード例 #3
0
 public EntityFrameworkRepositoryReadOnly(EnityFramWorkDbContext context)
 {
     _contextReadOnly = context;
 }