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 { } }
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"); }
// 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"])); }
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); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { AddSerilogLogger(); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); AqarPress.Core.Init.Empty(); var types = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(x => x.GetTypes()) .Where(p => typeof(ICreateInScope).IsAssignableFrom(p) && p.IsClass) .ToList(); types.ForEach(x => services.AddSingleton(x)); RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>( c => c.SetTraceLevel(TraceLevel.Verbose) .AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory)) .SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012)); }
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); } }
/// <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))); }
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); } }); }
// 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?}"); }); }
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)); }
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); }); }
/// <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))); }
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(); }
private void InitializeLlBlGenPro() { RuntimeConfiguration.ConfigureDQE <SD.LLBLGen.Pro.DQE.SqlServer.SQLServerDQEConfiguration>(c => c .SetTraceLevel(System.Diagnostics.TraceLevel.Verbose) .AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory))); //RuntimeConfiguration.SetDependencyInjectionInfo(new[] { typeof(TournamentManager.Validators.UserEntityValidator).Assembly }, new[] { "TournamentManager.Validators" }); RuntimeConfiguration.Tracing.SetTraceLevel("ORMPersistenceExecution", System.Diagnostics.TraceLevel.Verbose); RuntimeConfiguration.Tracing.SetTraceLevel("ORMPlainSQLQueryExecution", System.Diagnostics.TraceLevel.Verbose); LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration(Path.Combine(DirectoryLocator.GetTargetConfigurationPath(), "NLog.Internal.config")); TournamentManager.AppLogging.LoggerFactory = ServiceProvider.GetRequiredService <ILoggerFactory>(); }
/// <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); }
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); }
// 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" }); }); }
public static IDataAccessAdapter CreateAdapter(string connectionString, string environment = "Common") { //have to do this stuff for Core RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(c => c .SetTraceLevel(TraceLevel.Verbose) .AddDbProviderFactory(typeof(SqlClientFactory)) .SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012)); // we have to do this, otherwise the connection string will be overwritten correctly // but the database name in the generated entities/stored procedure calls will not foreach (var overwrite in GetCatelogOverwriteHashTable(environment)) { RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>(c => c .AddCatalogNameOverwrite(overwrite.Key, overwrite.Value)); } return(GetStandardAdapter(connectionString, environment)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { MCB.MasterPiece.Data.DaoClasses.CommonDaoBase.ActualConnectionString = MCB.Configuration.ServerConfig.GetConnectionString(5); // Configure the DQE RuntimeConfiguration.ConfigureDQE <SQLServerDQEConfiguration>( c => c.SetTraceLevel(TraceLevel.Verbose) .AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory)) .SetDefaultCompatibilityLevel(SqlServerCompatibilityLevel.SqlServer2012)); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/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(); // ****** // BLAZOR COOKIE Auth Code (begin) app.UseCookiePolicy(); app.UseAuthentication(); app.UseAuthorization(); // BLAZOR COOKIE Auth Code (end) // ****** app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapBlazorHub <App>(selector: "app"); endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}"); endpoints.MapFallbackToPage("/_Host"); }); }
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); } }
// 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))); }