Exemple #1
0
 public R Invoke <R>(Func <ArvenaDbContext, R> func)
 {
     using (var arvenaDbContext = new ArvenaDbContext(_customConfig))
     {
         return(func(arvenaDbContext));
     }
 }
Exemple #2
0
 public void Invoke(Action <ArvenaDbContext> action)
 {
     using (var arvenaDbContext = new ArvenaDbContext(_customConfig))
     {
         action(arvenaDbContext);
     }
 }
Exemple #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers()
            .AddNewtonsoftJson(options =>
                               options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                               );


            var customConfig = Configuration.GetSection(typeof(CustomConfig).Name).Get <CustomConfig>();

            //if (customConfig.IsProduction)
            //{
            //    customConfig.ConnectionString =
            //            string.Format(customConfig.ConnectionString, "yexrewgv", "yEddLBhAqpuYlHD5LOCIq3gXuHs6taI0", "tai.db.elephantsql.com", "yexrewgv");
            //}


            services.AddDbContext <ArvenaDbContext>(
                //options => options.UseSqlServer(customConfig.ConnectionString)
                );

            services.AddSingleton <ICustomConfig>(x => customConfig);
            DependencyInjection.RegisterModules(services);

            var t = new ArvenaDbContext(customConfig).Sklep.Take(5).ToList();
        }