public static void UseSqLite( this IDbProviderOptions options, string connectionString) { if (options == null) { throw new ArgumentNullException(nameof(options)); } var configuration = new Configuration { ConnectionFactory = new DbConnectionFactory <SqliteConnection>(connectionString, true), DocumentStorageFactory = new SqlDocumentStorageFactory(), IsolationLevel = IsolationLevel.Serializable }; options.ProviderName = "SQLite"; options.Configuration = configuration; }
public static void UseSqlServer( this IDbProviderOptions options, string connectionString) { if (options == null) { throw new ArgumentNullException(nameof(options)); } var configuration = new Configuration { ConnectionFactory = new DbConnectionFactory <SqlConnection>(connectionString, true), DocumentStorageFactory = new SqlDocumentStorageFactory(), IsolationLevel = IsolationLevel.ReadUncommitted }; options.ProviderName = "SQL Server"; options.Configuration = configuration; }
public static void UseInMemory( this IDbProviderOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } var connectionString = "Data Source=:memory:"; var configuration = new Configuration { ConnectionFactory = new DbConnectionFactory <SqliteConnection>(connectionString, true), DocumentStorageFactory = new InMemoryDocumentStorageFactory(), IsolationLevel = IsolationLevel.Serializable }; options.ProviderName = "InMemory"; options.Configuration = configuration; }
public static void AddSqlServerDbProvider(this ContainerBuilder builder, IDbProviderOptions options) { IConfiguration configruration = App.Configuration; // SQL Server Runtime Provider. builder.Register <SqlDbServiceProvider>() .As <IDbServiceProvider>() .As <IDbTransactionProvider>() .OnActivating((c, p) => { if (!string.IsNullOrEmpty(p.Named <string>("ConnectionString"))) { return(new SqlDbServiceProvider(p.Named <string>("ConnectionString"))); } else if (!string.IsNullOrEmpty(options.ConnectionString)) { return(new SqlDbServiceProvider(options.ConnectionString)); } else if (!string.IsNullOrEmpty(options.ConnectionStringName)) { return(new SqlDbServiceProvider(configruration["connectionStrings/" + options.ConnectionStringName])); } throw new ArgumentException("Database Connection String is not initialized."); }); builder.Register <SqlDbQueryStrategyProvider>().As <IDbQueryStrategyProvider>(); builder.Register <SqlDbParamChainProvider>().As <IDbParamChainProvider>().AsSingleInstance(); builder.Register <SqlDbQueryExpressionMemberNameParserProvider>().As <IDbQueryExpressionMemberNameParserProvider>().AsSingleInstance(); builder.Register <SqlDbQueryExpressionParserProvider>().As <IDbQueryExpressionParserProvider>().AsSingleInstance(); builder.Register <SqlDbTypeFinderProvider>().As <IDbTypeFinderProvider>().AsSingleInstance(); builder.Register <SqlDbSchemaStrategyProvider>().As <IDbSchemaStrategyProvider>(); builder.Register <SqlDbQueryAddExpressionNode>().As <IDbQueryExpressionNode>(); builder.Register <SqlDbEnumTableInspectorStrategy>().As <IDbEnumTableInspectorStrategy>(); builder.Register <SqlDbTableInspectorStrategy>().As <IDbTableInspectorStrategy>(); }