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);
        }
 public ProductRepository(EASVContext context)
 {
     _context = context;
 }
Пример #5
0
 public JokeRepository(EASVContext context)
 {
     _context = context;
 }
 public AllergyRepository(EASVContext context)
 {
     _context = context;
 }
 public IngredientRepository(EASVContext context)
 {
     _context = context;
 }