Esempio n. 1
0
        static void InitDatabase()
        {
            using (eShopContext _db = new eShopContext())
            {
                Console.WriteLine();
                Console.WriteLine("刪除 - 資料庫");

                _db.Database.EnsureDeleted();

                Console.WriteLine("新增 - 資料庫");

                _db.Database.EnsureCreated();

                Console.WriteLine();
                Console.WriteLine("資料庫初始化完成 !");
                Console.WriteLine();

                ProductMain _productMain;

                _productMain                = new ProductMain();
                _productMain.Schema         = "DYAJ93A900930IK";
                _productMain.Name           = "Microsoft Surface Pro (Core i7/16G/256G/W10P)";
                _productMain.SellPrice      = 70888;
                _productMain.ProductStorage = new ProductStorage()
                {
                    Storage = 75
                };
                _db.ProductMains.Add(_productMain);

                _productMain                = new ProductMain();
                _productMain.Schema         = "DYAJ93A900929IK";
                _productMain.Name           = "Microsoft Surface Pro (Core i5/8G/128G/W10P)";
                _productMain.SellPrice      = 51888;
                _productMain.ProductStorage = new ProductStorage()
                {
                    Storage = 75
                };
                _db.ProductMains.Add(_productMain);

                _productMain                = new ProductMain();
                _productMain.Schema         = "DYAJ93A900928IK";
                _productMain.Name           = "Microsoft Surface Pro (Core i3/4G/128G/W10P)";
                _productMain.SellPrice      = 41888;
                _productMain.ProductStorage = new ProductStorage()
                {
                    Storage = 75
                };
                _db.ProductMains.Add(_productMain);

                _db.SaveChanges();

                Console.WriteLine("資料內容初始化完成 !");
                Console.WriteLine();
            }
        }
Esempio n. 2
0
 public EventLogRepository(eShopContext context)
 {
     _context = context;
 }
Esempio n. 3
0
 public ProductRepository(eShopContext context)
 {
     _context = context;
 }
Esempio n. 4
0
 public UnitOfWork()
 {
     this._context = new eShopContext();
 }
Esempio n. 5
0
 public OrderRepository(eShopContext context)
 {
     _context = context;
 }