コード例 #1
0
        public UnitOfWork(DbOptions opt)
        {
            if (opt.Environment == "Development" && String.IsNullOrEmpty(opt.ConnectionString))
            {
                optionsStatic = new DbContextOptionsBuilder <EASVContext>()
                                .UseInMemoryDatabase("TheDB")
                                .Options;
                context = new EASVContext(optionsStatic);
            }
            else
            {
                var options = new DbContextOptionsBuilder <EASVContext>()
                              .UseSqlServer(opt.ConnectionString)
                              .Options;
                context = new EASVContext(options);
            }

            //CustomerRepository = new CustomerRepository(context);
        }
コード例 #2
0
        public UnitOfWork(DbOptions opt)
        {
            DbContextOptions <EASVContext> options;

            if (opt.Environment == "Development")
            {
                options = new DbContextOptionsBuilder <EASVContext>()
                          .UseInMemoryDatabase("TheDB")
                          .Options;
            }


            else
            {
                options = new DbContextOptionsBuilder <EASVContext>()
                          .UseSqlServer(opt.ConnectionString)
                          .Options;
            }

            context              = new EASVContext(options);
            ProductRepository    = new ProductRepository(context);
            IngredientRepository = new IngredientRepository(context);
        }
コード例 #3
0
        public UnitOfWork(DbOptions opt)
        {
            /*if (opt.Environment == "Development" && String.IsNullOrEmpty(opt.ConnectionString))
             * {*/
            optionsStatic = new DbContextOptionsBuilder <EASVContext>()
                            .UseInMemoryDatabase("TheDB")
                            .Options;
            context = new EASVContext(optionsStatic);

            /* }
             * else
             * {
             *   var options = new DbContextOptionsBuilder<EASVContext>()
             *   .UseSqlServer(opt.ConnectionString)
             *       .Options;
             *   context = new EASVContext(options);
             * }*/
            /*
             * //Ensure sql queries are created
             * context.Database.EnsureCreated();
             */
            ProductRepository    = new ProductRepository(context);
            IngredientRepository = new IngredientRepository(context);
        }
コード例 #4
0
 public ProductRepository(EASVContext context)
 {
     _context = context;
 }
コード例 #5
0
 public JokeRepository(EASVContext context)
 {
     _context = context;
 }
コード例 #6
0
 public AllergyRepository(EASVContext context)
 {
     _context = context;
 }
コード例 #7
0
 public IngredientRepository(EASVContext context)
 {
     _context = context;
 }