コード例 #1
0
        public static void SeedDb(WebShopAppContext ctx)
        {
            ctx.Database.EnsureDeleted();
            ctx.Database.EnsureCreated();

            var product = ctx.Product.Add(new Product()
            {
                ProductName = "LadyShoes",
                Picture     = "http://fp2w.org/assets/ext/blob.jpg",
                Gender      = "Male",
                Type        = "Glasses"
            }).Entity;

            var product2 = ctx.Product.Add(new Product()
            {
                ProductName = "Nighttime",
                Picture     = "http://fp2w.org/assets/ext/blob.jpg"
            }).Entity;

            var product3 = ctx.Product.Add(new Product()
            {
                ProductName = "Hello"
            }).Entity;

            var product4 = ctx.Product.Add(new Product()
            {
                ProductName = "Bugger"
            }).Entity;

            ctx.Customer.Add(new Customer()
            {
                Name     = "Heeeels",
                Products = product
            });

            ctx.SaveChanges();
        }
コード例 #2
0
 public CustomerRepository(WebShopAppContext ctx)
 {
     _ctx = ctx;
 }
コード例 #3
0
 public ProductRepository(WebShopAppContext ctx)
 {
     _ctx = ctx;
 }