public SQLiteDataSource AttachRules(SQLiteDataSource source) { return source.WithRules( new DateTimeRule("CreatedDate", DateTimeKind.Local, OperationTypes.Insert), new DateTimeRule("UpdatedDate", DateTimeKind.Local, OperationTypes.InsertOrUpdate), new UserDataRule("CreatedByKey", "EmployeeKey", OperationTypes.Insert), new UserDataRule("UpdatedByKey", "EmployeeKey", OperationTypes.InsertOrUpdate), new ValidateWithValidatable(OperationTypes.InsertOrUpdate) ); }
static TestBase() { Setup.AssemblyInit(); foreach (ConnectionStringSettings con in ConfigurationManager.ConnectionStrings) { var ds = new SQLiteDataSource(con.Name, con.ConnectionString); s_DataSources.Add(con.Name, ds); if (s_PrimaryDataSource == null) s_PrimaryDataSource = ds; } }
/// <summary> /// Creates a new data source with the indicated changes to the settings. /// </summary> /// <param name="settings">The new settings to use.</param> /// <returns></returns> /// <remarks>The new data source will share the same database metadata cache.</remarks> public SQLiteDataSource WithSettings(SQLiteDataSourceSettings settings) { var mergedSettings = new SQLiteDataSourceSettings() { DefaultCommandTimeout = settings?.DefaultCommandTimeout ?? DefaultCommandTimeout, SuppressGlobalEvents = settings?.SuppressGlobalEvents ?? SuppressGlobalEvents, StrictMode = settings?.StrictMode ?? StrictMode, DisableLocks = settings?.DisableLocks ?? DisableLocks, }; var result = new SQLiteDataSource(Name, m_ConnectionBuilder, mergedSettings, m_DatabaseMetadata, m_Cache, m_ExtensionCache); result.m_DatabaseMetadata = m_DatabaseMetadata; result.AuditRules = AuditRules; result.UserValue = UserValue; result.ExecutionStarted += (sender, e) => OnExecutionStarted(e); result.ExecutionFinished += (sender, e) => OnExecutionFinished(e); result.ExecutionError += (sender, e) => OnExecutionError(e); result.ExecutionCanceled += (sender, e) => OnExecutionCanceled(e); return(result); }
/// <summary> /// Creates a new data source with the indicated changes to the settings. /// </summary> /// <param name="settings">The new settings to use.</param> /// <returns></returns> /// <remarks>The new data source will share the same database metadata cache.</remarks> public SQLiteDataSource WithSettings(SQLiteDataSourceSettings settings) { var mergedSettings = new SQLiteDataSourceSettings() { DefaultCommandTimeout = settings?.DefaultCommandTimeout ?? DefaultCommandTimeout, SuppressGlobalEvents = settings?.SuppressGlobalEvents ?? SuppressGlobalEvents, StrictMode = settings?.StrictMode ?? StrictMode, DisableLocks = settings?.DisableLocks ?? DisableLocks, }; var result = new SQLiteDataSource(Name, m_ConnectionBuilder, mergedSettings, m_DatabaseMetadata, m_Cache, m_ExtensionCache); result.m_DatabaseMetadata = m_DatabaseMetadata; result.AuditRules = AuditRules; result.UserValue = UserValue; result.ExecutionStarted += (sender, e) => OnExecutionStarted(e); result.ExecutionFinished += (sender, e) => OnExecutionFinished(e); result.ExecutionError += (sender, e) => OnExecutionError(e); result.ExecutionCanceled += (sender, e) => OnExecutionCanceled(e); return result; }
static TestBase() { s_DataSource = new SQLiteDataSource("Data Source=SQLiteTestDatabase.sqlite;"); s_StrictDataSource = s_DataSource.WithSettings(new SQLiteDataSourceSettings() { StrictMode = true }); }
static TestBase() { s_DataSource = new SQLiteDataSource(System.Configuration.ConfigurationManager.ConnectionStrings["SQLiteTestDatabase"].ConnectionString); s_StrictDataSource = s_DataSource.WithSettings(new SQLiteDataSourceSettings() { StrictMode = true }); }