/// <summary> /// Initializes a new instance of the <see cref="SQLiteDataSource" /> class. /// </summary> /// <param name="name">The name of the data source.</param> /// <param name="connectionString">The connection string.</param> /// <param name="settings">Optional settings object.</param> /// <exception cref="ArgumentException">Connection string is null or emtpy.;connectionString</exception> public SQLiteDataSource(string name, string connectionString, SQLiteDataSourceSettings settings = null) : base(settings) { if (string.IsNullOrEmpty(connectionString)) { throw new ArgumentException("Connection string is null or emtpy.", "connectionString"); } m_ConnectionBuilder = new SQLiteConnectionStringBuilder(connectionString); if (string.IsNullOrEmpty(name)) { Name = m_ConnectionBuilder.DataSource; } else { Name = name; } m_DatabaseMetadata = new SQLiteMetadataCache(m_ConnectionBuilder); m_ExtensionCache = new ConcurrentDictionary <Type, object>(); m_Cache = DefaultCache; }
/// <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); }
SQLiteDataSource(string?name, SQLiteConnectionStringBuilder connectionStringBuilder, SQLiteDataSourceSettings settings, SQLiteMetadataCache databaseMetadata, ICacheAdapter cache, ConcurrentDictionary <Type, object> extensionCache) : base(settings) { if (connectionStringBuilder == null) { throw new ArgumentNullException(nameof(connectionStringBuilder), $"{nameof(connectionStringBuilder)} is null."); } m_ConnectionBuilder = connectionStringBuilder; if (string.IsNullOrEmpty(name)) { Name = m_ConnectionBuilder.DataSource; } else { Name = name; } m_DatabaseMetadata = databaseMetadata; m_ExtensionCache = extensionCache; m_Cache = cache; if (settings != null) { EnforceForeignKeys = settings.EnforceForeignKeys; } }
private SQLiteDataSource(string name, SQLiteConnectionStringBuilder connectionStringBuilder, SQLiteDataSourceSettings settings, SQLiteMetadataCache databaseMetadata, ICacheAdapter cache, ConcurrentDictionary <Type, object> extensionCache) : base(settings) { if (connectionStringBuilder == null) { throw new ArgumentNullException("connectionStringBuilder", "connectionStringBuilder is null."); } m_ConnectionBuilder = connectionStringBuilder; if (string.IsNullOrEmpty(name)) { Name = m_ConnectionBuilder.DataSource; } else { Name = name; } m_DatabaseMetadata = databaseMetadata; m_ExtensionCache = extensionCache; m_Cache = cache; }
/// <summary> /// Initializes a new instance of the <see cref="SQLiteDataSource" /> class. /// </summary> /// <param name="connectionString"></param> /// <param name="settings">Optional settings object.</param> public SQLiteDataSource(string connectionString, SQLiteDataSourceSettings settings = null) : this(null, connectionString, settings) { }
/// <summary> /// Initializes a new instance of the <see cref="SQLiteDataSource" /> class. /// </summary> /// <param name="connectionStringBuilder"></param> /// <param name="settings">Optional settings object.</param> public SQLiteDataSource(SQLiteConnectionStringBuilder connectionStringBuilder, SQLiteDataSourceSettings settings = null) : this(null, connectionStringBuilder, settings) { }