コード例 #1
0
 /// <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;
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.DatabaseProvider != null)
         {
             this.DatabaseProvider.Dispose();
             this.DatabaseProvider = null;
         }
     }
 }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        public static SqliteDatabaseProvider CreateInMemoryDatabase()
        {
            SqliteDatabaseProvider p = new SqliteDatabaseProvider("Data Source=:memory:", true);

            return(p);
        }