/// <summary> /// /// </summary> /// <param name="databaseProvider">attention: dispose of the snapshot disposes the provider!</param> /// <param name="tableName"></param> /// <param name="primaryKey"></param> public SqliteTableSnapshot(SqliteDatabaseProvider databaseProvider, string tableName, params string[] primaryKey) { Guard.ArgumentNotNull(databaseProvider, "databaseProvider"); Guard.ArgumentNotNullOrEmptyString(tableName, "tableName"); Guard.ArgumentNotNullOrEmptyList(primaryKey, "primaryKey"); this.DatabaseProvider = databaseProvider; this.TableName = tableName; this.PrimaryKey = primaryKey; }
private static ITableSnapshot OpenSqliteSnapshot(string fileName, string tableName, params string[] primaryKey) { Guard.AssertNotNullOrEmptyString(tableName); Guard.AssertNotNullOrEmptyString(fileName); SqliteDatabaseProvider p = SqliteDatabaseProvider.OpenDatabase(fileName); SqliteTableSnapshot sn = new SqliteTableSnapshot(p, tableName, primaryKey); return(sn); }
private void Dispose(bool disposing) { if (disposing) { if (this.DatabaseProvider != null) { this.DatabaseProvider.Dispose(); this.DatabaseProvider = null; } } }
public static SqliteDatabaseProvider OpenOrCreateDatabase(string filename, ITableBuilder tableBuilder) { Guard.ArgumentNotNull(filename, nameof(filename)); Guard.ArgumentNotNull(tableBuilder, nameof(tableBuilder)); if (FileExistsAndNotEmpty(filename)) { return(OpenDatabase(filename)); } else { SqliteDatabaseProvider p = CreateDatabase(filename); p.CreateTable(tableBuilder); return(p); } }
public static SqliteDatabaseProvider CreateInMemoryDatabase() { SqliteDatabaseProvider p = new SqliteDatabaseProvider("Data Source=:memory:", true); return(p); }