コード例 #1
0
        public static void Initialize(GummiDbContext context)
        {
            if (context.Products.Any())
            {
                return;
            }

            var products = new Product[]
            {
                new Product()
                {
                    Name = "Giant Gummi", Description = "12 oz. gummi bear", Cost = 499
                },
                new Product()
                {
                    Name = "Green Gummies", Description = "16 oz. bag  of green gummi bears", Cost = 6
                },
                new Product()
                {
                    Name = "Glitter Gummies", Description = "16 oz. bag  of pink and purple glittery gummi bears", Cost = 8
                },
                new Product()
                {
                    Name = "Shark Gummies", Description = "8 0z. bag of shark gummies", Cost = 4
                },
                new Product()
                {
                    Name = "Gummi Worms", Description = "16 oz. bag of rainbow colored gummi worms", Cost = 6
                },
                new Product()
                {
                    Name = "Red Hot Gummies", Description = "16 oz. bag  of red hot gummi bears", Cost = 3
                },
            };

            foreach (Product p in products)
            {
                context.Products.Add(p);
            }
            context.SaveChanges();
        }
コード例 #2
0
 public EFProductRepository(GummiDbContext thisDb)
 {
     db = thisDb;
 }
コード例 #3
0
 public EFProductRepository()
 {
     db = new GummiDbContext();
 }
コード例 #4
0
 public HomeController(GummiDbContext context)
 {
     _context = context;
 }
コード例 #5
0
 public EFReviewRepository(GummiDbContext thisDb)
 {
     db = thisDb;
 }
コード例 #6
0
 public EFReviewRepository()
 {
     db = new GummiDbContext();
 }
コード例 #7
0
 public CategoriesController(GummiDbContext context)
 {
     _context = context;
 }