Exemple #1
0
 public EFStoreRepository(StoreDbContext ctx)
 {
     context = ctx;
 }
 public EFOrderRepository(StoreDbContext context) =>
 this.context = context;
 public EFOrderRepository(StoreDbContext ctx)
 {
     context = ctx;
 }
        public static void EnsurePopulated(IApplicationBuilder app)
        {
            StoreDbContext context = app.ApplicationServices
                                     .CreateScope().ServiceProvider.GetRequiredService <StoreDbContext>();

            if (context.Database.GetPendingMigrations().Any())
            {
                context.Database.Migrate();
            }
            if (!context.Products.Any())
            {
                context.Products.AddRange(
                    new Product
                {
                    Name        = "Kayak",
                    Description = "A boat for one person",
                    Category    = "Watersports",
                    Price       = 275
                },
                    new Product
                {
                    Name        = "Lifejacket",
                    Description = "Protective and fashionable",
                    Category    = "Watersports",
                    Price       = 48.95m
                },
                    new Product
                {
                    Name        = "Soccer Ball",
                    Description = "FIFA-approved size and weight",
                    Category    = "Soccer",
                    Price       = 19.50m
                },
                    new Product
                {
                    Name        = "Corner Flags",
                    Description = "Give your playing field a professional touch",
                    Category    = "Soccer",
                    Price       = 34.95m
                }, new Product
                {
                    Name        = "Stadium",
                    Description = "Flat-packed 35,000-seat stadium",
                    Category    = "Soccer",
                    Price       = 79500
                },
                    new Product
                {
                    Name        = "Thinking Cap",
                    Description = "Improve brain efficiency by 75%",
                    Category    = "Chess",
                    Price       = 16
                },
                    new Product
                {
                    Name        = "Unsteady Chair",
                    Description = "Secretly give your opponent a disadvantage",
                    Category    = "Chess",
                    Price       = 29.95m
                },
                    new Product
                {
                    Name        = "Human Chess Board",
                    Description = "A fun game for the family",
                    Category    = "Chess",
                    Price       = 75
                },
                    new Product
                {
                    Name        = "Bling-Bling King",
                    Description = "Gold-plated, diamond-studded King",
                    Category    = "Chess",
                    Price       = 1200
                }
                    );
                context.SaveChanges();
            }
        }
Exemple #5
0
 public EFStoreRepository(StoreDbContext context)
 {
     this.context = context;
 }
 public EfStoreRepository(StoreDbContext ctx)
 {
     _context = ctx;
 }
 public EFOrderRepository(StoreDbContext injectedContext)
 {
     context = injectedContext;
 }
Exemple #8
0
 public EFStoreRepository(StoreDbContext context)
 {
     this.context = context ?? throw new ArgumentNullException(nameof(context));
 }
Exemple #9
0
 public EFOrderRepository(StoreDbContext context)
 {
     _context = context;
 }
Exemple #10
0
 public EFStoreRepository(StoreDbContext storeDbContext)
 {
     context = storeDbContext;
 }
Exemple #11
0
 public EFOrderRepository(StoreDbContext storeDbContext)
 {
     _storeDbContext = storeDbContext;
 }
Exemple #12
0
 public EFStoreRepository(StoreDbContext ctx) // To talk to SQL server, This repository needs DbContext that's why it's injected here.
 {
     context = ctx;
 }
Exemple #13
0
 public EFOrderRepository(StoreDbContext dbContext)
 {
     context = dbContext;
 }