예제 #1
0
 public llbl()
 {
     RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(
         c => c.AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory)));
     RuntimeConfiguration.AddConnectionString
         ("ConnectionString.SQL Server (SqlClient)", "data source=DESKTOP-CUE6HRC;initial catalog=llbl; Integrated Security=SSPI");
 }
예제 #2
0
        public static void AssemblyInit(TestContext context)
        {
            var configuration = new ConfigurationBuilder().SetBasePath(AppContext.BaseDirectory).AddJsonFile("appsettings.json").Build();
            var sqlServerConnectionString = configuration.GetSection("ConnectionStrings")["SqlServerTestDatabase"];
            RuntimeConfiguration.AddConnectionString("ConnectionString.SQL Server (SqlClient)", sqlServerConnectionString);
	
// change to TRUE to have ORM Profiler monitoring. Won't work with Connection Sharing.  
#if FALSE			
            // Wrap the factory with a factory from the ORM Profiler so we get real time information about what's going on
            // ORM Profiler is a free tool for LLBLGen Pro subscribers.
            RuntimeConfiguration.ConfigureDQE<SQLServerDQEConfiguration>(c => c.AddDbProviderFactory(InterceptorCore.Initialize("ORM Cookbook",
                                                                                                     typeof(Microsoft.Data.SqlClient.SqlClientFactory)))
                                                                               .SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012));
#else
			RuntimeConfiguration.ConfigureDQE<SQLServerDQEConfiguration>(c => c.AddDbProviderFactory(typeof(Microsoft.Data.SqlClient.SqlClientFactory))
#endif
																			   .SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012));
            RuntimeConfiguration.Entity.SetMarkSavedEntitiesAsFetched(true);
			// Setup the dependency injection system to auto-inject e.g. auditors when needed. 
			RuntimeConfiguration.SetDependencyInjectionInfo(new List<Assembly>() { typeof(DepartmentAuditor).Assembly}, null);
			
            try
            {
                (new Setup()).Warmup();
            }
            catch { }
        }
예제 #3
0
        private void ConfigureLlblgenPro()
        {
            var dbContextList = DbContextList.DeserializeFromFile(Path.Combine(WebHostEnvironment.ContentRootPath, Program.ConfigurationFolder, $"DbContextList.{WebHostEnvironment.EnvironmentName}.config"));

            foreach (var dbContext in dbContextList)
            {
                var connectionString = Configuration.GetConnectionString(dbContext.ConnectionKey);
                RuntimeConfiguration.AddConnectionString(dbContext.ConnectionKey, connectionString);
                // Enable low-level (result set) caching when specified in selected queries
                // The cache of a query can be overwritten using property 'OverwriteIfPresent'
                CacheController.RegisterCache(connectionString, new ResultsetCache());
                CacheController.CachingEnabled = true;
            }

            //RuntimeConfiguration.SetDependencyInjectionInfo(new[] { typeof(TournamentManager.EntityValidators.UserEntityValidator).Assembly }, new[] { "TournamentManager.Validators" });

            if (WebHostEnvironment.IsProduction())
            {
                RuntimeConfiguration.ConfigureDQE <SD.LLBLGen.Pro.DQE.SqlServer.SQLServerDQEConfiguration>(c => c
                                                                                                           .SetTraceLevel(TraceLevel.Off)
                                                                                                           .AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory)));
            }
            else
            {
                RuntimeConfiguration.ConfigureDQE <SD.LLBLGen.Pro.DQE.SqlServer.SQLServerDQEConfiguration>(c => c
                                                                                                           .SetTraceLevel(TraceLevel.Verbose)
                                                                                                           .AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory)));

                RuntimeConfiguration.Tracing.SetTraceLevel("ORMPersistenceExecution", TraceLevel.Verbose);
                RuntimeConfiguration.Tracing.SetTraceLevel("ORMPlainSQLQueryExecution", TraceLevel.Verbose);
            }
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LLBLGenProNormalBencher"/> class.
 /// </summary>
 public LLBLGenProNormalBencher(string connectionString)
     : base(e => e.SalesOrderId, l => l.CreditCardId, usesChangeTracking: true, usesCaching: false, supportsEagerLoading: true, supportsAsync: true, supportsInserts: true)
 {
     EntityBase2.MarkSavedEntitiesAsFetched = true;
     RuntimeConfiguration.AddConnectionString("AdventureWorks.ConnectionString.SQL Server (SqlClient)", connectionString);
     RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(c => c.AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory)));
 }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();
            app.UseCors("AllowCors");


            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });



            RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(c => c.AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory)));
            RuntimeConfiguration.AddConnectionString(Configuration["ConnectionStrings:StringKey"], Configuration["ConnectionStrings:DefaultConnection"]);
            RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(c => c.SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012));
            RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(c => c.AddCatalogNameOverwrite("HARS_Susmita", Configuration["ConnectionStrings:CatalogNameToUse"]));
        }
예제 #6
0
        private void ConfigureLLBLGenPro(IServiceCollection services)
        {
            var llblgenProConfig = new LLBLGenProConfiguration();

            _configuration.Bind("LLBLGenPro", llblgenProConfig);
            llblgenProConfig.Sanitize();
            var connectionString = _configuration.GetConnectionString("Main.ConnectionString.SQL Server (SqlClient)");

            if (!string.IsNullOrEmpty(connectionString) !)
            {
                RuntimeConfiguration.AddConnectionString("Main.ConnectionString.SQL Server (SqlClient)", connectionString);
            }

            foreach (var kvp in llblgenProConfig.ConnectionStrings)
            {
                RuntimeConfiguration.AddConnectionString(kvp.Key, kvp.Value);
            }

            var factoryType = typeof(Microsoft.Data.SqlClient.SqlClientFactory);

#if DEBUG
            // only intercept queries using the profiler in debug builds.
            factoryType = InterceptorCore.Initialize("HnD", factoryType);
#endif
            RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(c =>
            {
                c.AddDbProviderFactory(factoryType)
                .SetDefaultCompatibilityLevel(llblgenProConfig.SqlServerCompatibilityAsEnum);

                foreach (var kvp in llblgenProConfig.CatalogNameOverwrites)
                {
                    c.AddCatalogNameOverwrite(kvp.Key, kvp.Value);
                }
            });
        }
예제 #7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            RuntimeConfiguration.AddConnectionString("ConnectionString.SQL Server (SqlClient)", @"data source=DESKTOP-K7BKMEJ\SQLEXPRESS;initial catalog=Vehicle;integrated security=SSPI;persist security info=False;packet size=4096");
            RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(
                c => c.SetTraceLevel(TraceLevel.Verbose)
                .AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory))
                .SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012));

            RuntimeConfiguration.Tracing
            .SetTraceLevel("ORMPersistenceExecution", TraceLevel.Info);
            RuntimeConfiguration.Entity
            .SetMarkSavedEntitiesAsFetched(true);

            app.UseCors(options => options.WithOrigins().AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin());
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=VehicleMake}/{action=Index}/{id?}");
            });
        }
예제 #8
0
        private void ConfigureLlblgenPro(TenantStore tenantStore)
        {
            foreach (var tenant in tenantStore.GetTenants().Values)
            {
                var connectionString = Configuration.GetConnectionString(tenant.DbContext.ConnectionKey);
                RuntimeConfiguration.AddConnectionString(tenant.DbContext.ConnectionKey, connectionString);
                // Enable low-level (result set) caching when specified in selected queries
                // The cache of a query can be overwritten using property 'OverwriteIfPresent'
                CacheController.RegisterCache(connectionString, new ResultsetCache());
                CacheController.CachingEnabled = true;
            }

            if (WebHostEnvironment.IsProduction())
            {
                RuntimeConfiguration.ConfigureDQE <SD.LLBLGen.Pro.DQE.SqlServer.SQLServerDQEConfiguration>(c => c
                                                                                                           .SetTraceLevel(TraceLevel.Off)
                                                                                                           .AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory)));
            }
            else
            {
                RuntimeConfiguration.ConfigureDQE <SD.LLBLGen.Pro.DQE.SqlServer.SQLServerDQEConfiguration>(c => c
                                                                                                           .SetTraceLevel(TraceLevel.Verbose)
                                                                                                           .AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory)));

                RuntimeConfiguration.Tracing.SetTraceLevel("ORMPersistenceExecution", TraceLevel.Verbose);
                RuntimeConfiguration.Tracing.SetTraceLevel("ORMPlainSQLQueryExecution", TraceLevel.Verbose);
            }
        }
예제 #9
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                //EF database error page provider, not using
                //app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });

            //LLBLGen
            //config hard-coded
            //RuntimeConfiguration.AddConnectionString("ConnectionString.SQL Server (SqlClient)", "data source=YOURCOMPUTER\\SQLINSTANCE;initial catalog=Snoffleware-LLBLGen-Identity-Dev;integrated security=SSPI;persist security info=False");

            //but we don't want to do this so we will pull from the new Secret Manager store locally
            //*** add a key to the secrets store for _each_ project that needs to access data through LLBLGen ***
            //*** "ConnectionString.SQL Server (SqlClient)" plus your connection string ***

            //careful, secrets holds on to a double-wack-slash so it will double and not work when you pull it forward.
            //-- i.e. don't escape the connection string when you pass it to the Secret Manager via the command line, see:
            //https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets/

            //example powershell command in README...

            string connectionStringKey   = "ConnectionString.SQL Server (SqlClient)";
            string connectionStringValue = Configuration[connectionStringKey];

            RuntimeConfiguration.AddConnectionString(connectionStringKey, connectionStringValue);

            RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(
                c => c.SetTraceLevel(TraceLevel.Verbose)
                //.AddCatalogNameOverwrite("Snoffleware-LLBLGen-Identity-Dev", "")  //may be necessary on azure
                .AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory))
                .SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012));
        }
예제 #10
0
        private void ConfigureLlbl()
        {
            string cs = Configuration.GetConnectionString("WeeksPlanning");

            RuntimeConfiguration.AddConnectionString("ConnectionString.SQL Server (SqlClient)", cs);
            RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(c =>
            {
                c.AddDbProviderFactory(typeof(SqlClientFactory));
                c.SetTraceLevel(TraceLevel.Verbose);
            });
        }
        public static void LLBLGen(IConfiguration config)
        {
            RuntimeConfiguration.AddConnectionString("ConnectionString.SQL Server (SqlClient)", config["ConnectionStrings:Licenses_Generator.Module"]);
            RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(c =>
            {
                c.AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory))
                .SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012);

                c.SetTraceLevel(System.Diagnostics.TraceLevel.Verbose);
            });
        }
예제 #12
0
        /// <summary>
        /// sets up the RuntimeDatabaseContext for LLBLGen ORM
        /// </summary>
        public void ConfigureRuntimeDataContext()
        {
            //set up the PostgreSQL connection for LLBLGen ORM
            var connectionString = Configuration.GetConnectionString("JwtSecurityConn");

            RuntimeConfiguration.AddConnectionString("JwtSecurityConn",
                                                     connectionString);

            RuntimeConfiguration.ConfigureDQE <PostgreSqlDQEConfiguration>(
                c => c.AddDbProviderFactory(typeof(Npgsql.NpgsqlFactory)));
        }
예제 #13
0
        public static void LlblGen(IConfiguration config)
        {
            NpgsqlConnection.GlobalTypeMapper.UseNetTopologySuite(geographyAsDefault: true);

            RuntimeConfiguration.AddConnectionString("ConnectionString.PostgreSql (Npgsql)", config["connectionStrings"]);

            RuntimeConfiguration.ConfigureDQE <PostgreSqlDQEConfiguration>(c =>
            {
                c.AddDbProviderFactory(typeof(NpgsqlFactory));
            });
            NpgsqlConnection.GlobalTypeMapper.UseNetTopologySuite();
        }
예제 #14
0
        /// <summary>
        /// Sets up the connection to LLBLGen
        /// http://llblgen.com/Documentation/5.3/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/gencode_runtimeconfiguration.htm
        /// </summary>
        /// <param name="databaseConnection"></param>
        public static void Setup(string databaseConnection)
        {
            RuntimeConfiguration.AddConnectionString("ConnectionString.SQL Server (SqlClient)", databaseConnection);

            RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(
                c => c.SetTraceLevel(TraceLevel.Verbose)
                .AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory))
                .SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012));

            RuntimeConfiguration.Tracing
            .SetTraceLevel("ORMPersistenceExecution", TraceLevel.Verbose)
            .SetTraceLevel("ORMPlainSQLQueryExecution", TraceLevel.Verbose);
        }
예제 #15
0
        public static IApplicationBuilder UseLLBLGen(this IApplicationBuilder app)
        {
            // ... this code is placed in a method called at application startup
            RuntimeConfiguration.AddConnectionString(
                "ConnectionString.SQL Server (SqlClient)",
                GetConnectionString());

            // Configure the DQE
            RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(c => c.SetTraceLevel(TraceLevel.Verbose)
                                                                          .AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory))
                                                                          .SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012));

            return(app);
        }
예제 #16
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Configure the LLBLGen Pro Runtime here with calls to RuntimeConfiguration
            RuntimeConfiguration.AddConnectionString("ConnectionString.SQL Server (SqlClient)",
                                                     this.Configuration.GetConnectionString("ConnectionString.SQL Server (SqlClient)"));
            RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(c =>
            {
                // add more here...
                c.AddDbProviderFactory(typeof(Microsoft.Data.SqlClient.SqlClientFactory));
            });

            services.AddControllers();
            services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "NWSvc", Version = "v1"
                }); });
        }
예제 #17
0
        static async Task Main(string[] args)
        {
            // The generated code is a netstandard variant, so we have to use the RuntimeConfiguration class.
            RuntimeConfiguration.AddConnectionString("Main.ConnectionString.SQL Server (SqlClient)",
                                                     ConfigurationManager.AppSettings["Main.ConnectionString.SQL Server (SqlClient)"]);
            RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(c =>
            {
                c.AddCatalogNameOverwrite("HnD", ConfigurationManager.AppSettings["DestinationCatalog"]);
                c.AddDbProviderFactory(typeof(SqlClientFactory));
            });

            try
            {
                LoadXsltTemplates();
                ConvertForumWelcomeTexts();
                ConvertThreadMemos();
                ConvertUsers();
                await ConvertMessages();
            }
            catch (Exception ex)
            {
                DisplayException(ex);
            }
        }
예제 #18
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var connectionString           = Configuration.GetConnectionString("DefaultConnection");
            var todoListConnectionString   = Configuration.GetConnectionString("TodoList");
            var animalFarmConnectionString = Configuration.GetConnectionString("AnimalFarm");

            switch (Environment.GetEnvironmentVariable("ORM"))
            {
            case "Dapper":
                services.AddScoped <IWeatherService>(impl => new MTech.DapperSample.WeatherService(new SqlConnection(connectionString)));
                services.AddScoped <ITodoService>(impl => new MTech.DapperSample.TodoService(new SqlConnection(todoListConnectionString)));
                services.AddScoped <IAnimalService>(implementationFactory => new MTech.DapperSample.AnimalService(new SqlConnection(animalFarmConnectionString)));
                break;

            case "EFCore":

                services.AddDbContext <MTech.EFSample.WeatherContext>(options =>
                {
                    options.UseSqlServer(connectionString);
                });

                services.AddScoped <IWeatherService, MTech.EFSample.WeatherService>();

                services.AddDbContext <MTech.EFSample.TodoContext>(options =>
                {
                    options.UseSqlServer(todoListConnectionString);
                });
                services.AddScoped <ITodoService, MTech.EFSample.TodoService>();

                services.AddDbContext <MTech.EFSample.AnimalContext>(options =>
                {
                    options.UseSqlServer(animalFarmConnectionString);
                });
                services.AddScoped <IAnimalService, MTech.EFSample.AnimalService>();
                break;

            case "Linq2Db":
                services.AddLinqToDbContext <MTech.LinqToDBSample.WeatherConnection>((provider, options) =>
                {
                    options.UseSqlServer(connectionString);
                });
                services.AddScoped <IWeatherService, MTech.LinqToDBSample.WeatherService>();

                services.AddLinqToDbContext <MTech.LinqToDBSample.TodoDataConnection>((provider, options) =>
                {
                    options.UseSqlServer(todoListConnectionString);
                });
                services.AddScoped <ITodoService, MTech.LinqToDBSample.TodoService>();

                services.AddLinqToDbContext <MTech.LinqToDBSample.AnimalConnection>((provider, options) =>
                {
                    options.UseSqlServer(animalFarmConnectionString);
                });
                services.AddScoped <IAnimalService, MTech.LinqToDBSample.AnimalService>();
                break;

            case "LLBLGen":
                RuntimeConfiguration.AddConnectionString("WeatherContext", connectionString);
                RuntimeConfiguration.AddConnectionString("TodoContext", todoListConnectionString);
                RuntimeConfiguration.AddConnectionString("AnimalContext", animalFarmConnectionString);
                RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(
                    c => c.SetTraceLevel(TraceLevel.Verbose)
                    .AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory))
                    .SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012));

                services.AddScoped <IWeatherService, MTech.LLBLGenSample.WeatherService>();
                services.AddScoped <ITodoService, MTech.LLBLGenSample.TodoService>();
                services.AddScoped <IAnimalService, MTech.LLBLGenSample.AnimalService>();
                break;

            case "NHibernate":
                services.AddNHibernate(connectionString, typeof(WeatherMapping));
                services.AddNHibernate(todoListConnectionString, typeof(TodoItemMapping));
                services.AddNHibernate(animalFarmConnectionString,
                                       typeof(AnimalMapping),
                                       typeof(DogMapping),
                                       typeof(CowMapping));
                services.AddScoped <IWeatherService, MTech.NHibernateSample.WeatherService>();
                services.AddScoped <ITodoService, MTech.NHibernateSample.TodoService>();
                services.AddScoped <IAnimalService, MTech.NHibernateSample.AnimalService>();
                break;

            case "SQL":
                services.AddScoped <IWeatherService>(impl => new MTech.SQLSample.WeatherService(new SqlConnection(connectionString)));
                services.AddScoped <ITodoService>(impl => new MTech.SQLSample.TodoService(new SqlConnection(todoListConnectionString)));
                services.AddScoped <IAnimalService>(impl => new MTech.SQLSample.AnimalService(new SqlConnection(animalFarmConnectionString)));
                break;
            }

            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "TodoApi", Version = "v1"
                });
            });
        }
        public async Task Setup()
        {
            var services = new ServiceCollection();

            IdentityBuilder builder = services.AddIdentityCore <ApplicationUser>();

            builder.AddUserStore <UserStore>();
            builder.AddRoles <ApplicationRole>();
            builder.AddRoleStore <RoleStore>();

            services.Configure <IdentityOptions>(options =>
            {
                options.User.RequireUniqueEmail         = true;
                options.Lockout.DefaultLockoutTimeSpan  = TimeSpan.FromMinutes(5);
                options.Lockout.MaxFailedAccessAttempts = 10;
                options.Password.RequiredLength         = 8;
                options.Password.RequireDigit           = true;
                options.Password.RequiredUniqueChars    = 1;
                options.Password.RequireNonAlphanumeric = true;
                options.Password.RequireUppercase       = true;
                options.Password.RequireLowercase       = true;
            });

            services.Configure <CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddMvcCore();

            _userManager = services.BuildServiceProvider().GetService <UserManager <ApplicationUser> >();
            _roleManager = services.BuildServiceProvider().GetService <RoleManager <ApplicationRole> >();


            //LLBLGen
            //config hard-coded
            //if you want to run it without setting up the user secrets, you can just add your connection string manually
            //and comment out the 4 lines below that add the connection string using secrets
            //RuntimeConfiguration.AddConnectionString("ConnectionString.SQL Server (SqlClient)", "data source=YOURCOMPUTER\\SQLINSTANCE;initial catalog=Snoffleware-LLBLGen-Identity-Dev;integrated security=SSPI;persist security info=False");

            ////but we don't want to do this so we will pull from the new Secret Manager store locally
            ////*** add a key to the secrets store for _each_ project that needs to access data through LLBLGen ***
            ////*** "ConnectionString.SQL Server (SqlClient)" plus your connection string ***

            ////careful, secrets holds on to a double-wack-slash so it will double and not work when you pull it forward.
            ////-- i.e. don't escape the connection string when you pass it to the Secret Manager via the command line, see:
            ////https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets/
            ///
            //string connectionStringKey = "ConnectionString.SQL Server (SqlClient)";
            //string connectionStringValue = Configuration[connectionStringKey];
            //RuntimeConfiguration.AddConnectionString(connectionStringKey, connectionStringValue);

            //this doesn't work in the test project because we need to manually build the Configuration object for accessing Secret Manager
            string connectionStringKey = "ConnectionString.SQL Server (SqlClient)";

            ConfigurationUtility.GetIConfigurationRoot();
            string connectionStringValue = ConfigurationUtility.GetSecret(connectionStringKey);

            RuntimeConfiguration.AddConnectionString(connectionStringKey, connectionStringValue);
            RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(
                c => c.SetTraceLevel(TraceLevel.Verbose)
                //.AddCatalogNameOverwrite("Snoffleware-LLBLGen-Identity-Dev", "")  //may be necessary on azure
                .AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory))
                .SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LLBLGenProNoChangeTrackingQuerySpecPocoBencher"/> class.
 /// </summary>
 public LLBLGenProNoChangeTrackingQuerySpecPocoBencher(string connectionString)
     : base(r => r.SalesOrderId, usesChangeTracking: false, usesCaching: false)
 {
     RuntimeConfiguration.AddConnectionString("AdventureWorks.ConnectionString.SQL Server (SqlClient)", connectionString);
     RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(c => c.AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory)));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LLBLGenProResultsetCachingBencher"/> class.
 /// </summary>
 public LLBLGenProResultsetCachingBencher(string connectionString)
     : base(e => e.SalesOrderId, usesChangeTracking: true, usesCaching: true)
 {
     RuntimeConfiguration.AddConnectionString("AdventureWorks.ConnectionString.SQL Server (SqlClient)", connectionString);
     RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(c => c.AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory)));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LLBLGenProDTOBencher"/> class.
 /// </summary>
 public LLBLGenProDTOBencher(string connectionString)
     : base(r => r.SalesOrderId, usesChangeTracking: false, usesCaching: false, supportsAsync: true, supportsEagerLoading: true, supportsIndividualFetch: false, supportsSetFetch: false)
 {
     RuntimeConfiguration.AddConnectionString("AdventureWorks.ConnectionString.SQL Server (SqlClient)", connectionString);
     RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(c => c.AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory)));
 }
        private static void configureFromConfiguration(IConfiguration configuration)
        {
            var llblGenSettings = configuration.GetSection("LLBLGen");

            var traceSettings =
                llblGenSettings.GetSection("Tracing");

            List <IConfigurationSection> traceSwitches =
                traceSettings.GetSection("Switches").GetChildren().ToList();

            var traceListeners =
                traceSettings.GetSection("Listeners");

            List <IConfigurationSection> connectionStrings =
                configuration.GetSection("ConnectionStrings").GetChildren().ToList();

            if (!connectionStrings.Any())
            {
                connectionStrings =
                    llblGenSettings.GetSection("ConnectionStrings").GetChildren().ToList();
            }

            List <IConfigurationSection> catalogNameOverwrites =
                llblGenSettings.GetSection("SqlServerCatalogNameOverwrites").GetChildren().ToList();

            var isTraceEnabled = false;

            foreach (var traceSwitch in traceSwitches.Where(s => s.Key != "SqlServerDQE"))
            {
                if (!int.TryParse(traceSwitch.Value, out var value))
                {
                    continue;
                }

                if (value > 0)
                {
                    isTraceEnabled = true;
                }

                RuntimeConfiguration.Tracing
                .SetTraceLevel(traceSwitch.Key, (TraceLevel)value);
            }

            foreach (var connection in connectionStrings)
            {
                RuntimeConfiguration.AddConnectionString($"{connection.Key}.ConnectionString", connection.Value);
            }

            RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(config => {
                config
                .AddDbProviderFactory(typeof(SqlClientFactory))
                .SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012);

                var dqeTraceSetting =
                    traceSwitches.FirstOrDefault(s => s.Key == "SqlServerDQE");

                if (dqeTraceSetting != null)
                {
                    if (int.TryParse(dqeTraceSetting.Value, out var value))
                    {
                        if (value > 0)
                        {
                            isTraceEnabled = true;
                        }
                        config.SetTraceLevel((TraceLevel)value);
                    }
                }

                foreach (var catalogNameOverwrite in catalogNameOverwrites)
                {
                    var catalogName =
                        catalogNameOverwrite.GetChildren()?.FirstOrDefault(s => s.Key == "CatalogName")?.Value;

                    if (catalogName == null)
                    {
                        continue;
                    }

                    var overwrite =
                        catalogNameOverwrite.GetChildren()?.FirstOrDefault(s => s.Key == "Overwrite")?.Value;

                    config.AddCatalogNameOverwrite(catalogName, overwrite ?? string.Empty);
                }
            });

            if (!isTraceEnabled || !traceListeners.GetChildren().Any())
            {
                return;
            }

            var logToConsole = traceListeners.GetValue <bool>("Console");
            var logToDebug   = traceListeners.GetValue <bool>("Debug");
            var logFileName  = traceListeners.GetValue <string>("File");

            Trace.Listeners.Clear();

            if (logToConsole)
            {
                Trace.Listeners.Add(new TextWriterTraceListener(Console.Out, "Console"));
            }

            if (logToDebug)
            {
                Trace.Listeners.Add(new DefaultTraceListener {
                    Name        = "Debug",
                    LogFileName = logFileName
                });
                return;
            }

            if (string.IsNullOrEmpty(logFileName))
            {
                Trace.Listeners.Add(new TextWriterTraceListener(logFileName, "File"));
            }
        }