/// <summary> /// Initializes a new instance of the <see cref="BulkInsertOptions" /> class. /// </summary> /// <param name="tableInfo"> Destination schema name</param> /// <param name="sqlConnectionConfiguration">sql database configuration</param> public BulkInsertOptions(TableAttribute tableInfo, ISqlConnectionOptions sqlConnectionConfiguration) { tableInfo = Arguments.EnsureNotNull(tableInfo, nameof(tableInfo)); Arguments.NotNull(sqlConnectionConfiguration, nameof(sqlConnectionConfiguration)); this.SqlConnection = sqlConnectionConfiguration; this.DestinationSchemaName = tableInfo.Schema ?? "dbo"; this.DestinationTableName = tableInfo.Name; this.LogOptions = true; }
/// <inheritdoc/> public DbContextOptions <TContext> Convert(ISqlConnectionOptions from) { from = Arguments.EnsureNotNull(from, nameof(from)); var optionsBuilder = new DbContextOptionsBuilder <TContext>(); optionsBuilder.UseSqlServer(from.ConnectionString); var options = optionsBuilder.Options; return(options); }
// private bool isInMemory; /// <summary> /// Initializes a new instance of the <see cref="BaseContext{TContext}" /> class. /// </summary> /// <param name="options">injected sql connection options</param> /// <param name="adapter">injected adapter</param> /// <param name="logger">injected logger</param> protected BaseContext(ISqlConnectionOptions options, IDbContextOptionsAdapter <TContext> adapter, ILogger logger) : base(Arguments.EnsureNotNull(adapter, nameof(adapter)).Convert(options)) { Arguments.NotNull(options, nameof(options)); Arguments.NotNull(logger, nameof(logger)); this.SqlConnectionConfiguration = options; this.Logger = logger; this.CheckSchemaAgainstEntityModels(); // TODO: //// Database.SetInitializer<TContext>(null); // This only works if CodeMigrations are used //// this.Database.CompatibleWithModel(true); //// Database.SetInitializer(new MigrateDatabaseToLatestVersion<TContext, SchemaValidationConfiguration<TContext>>()); // TODO: //// this.Database.CommandTimeout = (int)this.SqlConnectionConfiguration.CommandTimeout.TotalSeconds; }
/// <summary> /// Initializes a new instance of the <see cref="SqlBulkCopyStorage{TRecord, TContext}" /> class. /// </summary> /// <param name="sqlConnectionConfiguration">sql connection information</param> /// <param name="logger">injected logger</param> public SqlBulkCopyStorage(ISqlConnectionOptions sqlConnectionConfiguration, ILogger logger) : this(new BulkInsertOptions(ReflectionHelper.SingleOrDefaultAttribute <TableAttribute>(typeof(TRecord)) !, sqlConnectionConfiguration), logger)
/// <summary> /// Initializes a new instance of the <see cref="BulkInsertOptions" /> class. /// </summary> /// <param name="schemaName"> Destination schema name</param> /// <param name="tableName"> Destination tchema name</param> /// <param name="sqlConnectionConfiguration">sql database configuration</param> public BulkInsertOptions(string schemaName, string tableName, ISqlConnectionOptions sqlConnectionConfiguration) { this.SqlConnection = sqlConnectionConfiguration; this.DestinationSchemaName = schemaName; this.DestinationTableName = tableName; }
/// <inheritdoc/> protected override void OnRegister(ISqlConnectionOptions configuration, IDbContextOptionsAdapter <TContext> adapter) { this.Container.RegisterAbbotwareContext <TContext>(configuration, adapter); }
/// <summary> /// Registers an Abbotware BaseContext /// </summary> /// <typeparam name="TContext">context type</typeparam> /// <param name="container">container</param> /// <param name="connection">connection configuration</param> /// <param name="adapter">options adapter</param> public static void RegisterAbbotwareContext <TContext>(this IWindsorContainer container, ISqlConnectionOptions connection, IDbContextOptionsAdapter <TContext> adapter) where TContext : BaseContext <TContext> { container = Arguments.EnsureNotNull(container, nameof(container)); connection = Arguments.EnsureNotNull(connection, nameof(connection)); container.Register(Component.For <TContext>() .ImplementedBy <TContext>() .LifestyleTransient() .DependsOn(Dependency.OnValue <ISqlConnectionOptions>(connection)) .DependsOn(Dependency.OnValue <IDbContextOptionsAdapter <TContext> >(adapter))); }
/// <summary> /// Registers an Abbotware BaseContext /// </summary> /// <typeparam name="TContext">context type</typeparam> /// <param name="container">container</param> /// <param name="options">connection configuration</param> /// <param name="adapter">options adapter</param> public static void RegisterDbContext <TContext>(this IWindsorContainer container, ISqlConnectionOptions options, IDbContextOptionsAdapter <TContext> adapter) where TContext : DbContext { container = Arguments.EnsureNotNull(container, nameof(container)); adapter = Arguments.EnsureNotNull(adapter, nameof(adapter)); Arguments.NotNull(options, nameof(options)); container.Register(Component.For <TContext>() .ImplementedBy <TContext>() .LifestyleTransient() .DependsOn(Dependency.OnValue <DbContextOptions <TContext> >(adapter.Convert(options)))); }