private void ApplyDatabaseSchema(IStorage storage, string databaseScriptFullPath) { string schemaScript; using (StreamReader reader = File.OpenText(databaseScriptFullPath)) { schemaScript = reader.ReadToEnd(); } IDbConnection connection = storage.Connect(); using (var unitOfWork = new SqLiteUnitOfWork(storage.Connect())) { unitOfWork.BeginTransaction(); using (IDbCommand command = connection.CreateCommand()) { command.CommandText = schemaScript; command.ExecuteNonQuery(); } unitOfWork.Commit(); } }
private int GetDdTablesCount(IStorage sqLiteStorage) { IDbConnection connection = sqLiteStorage.Connect(); using (connection.BeginTransaction()) { using (IDbCommand command = connection.CreateCommand()) { command.CommandText = "SELECT count(*) FROM sqlite_master WHERE type='table';"; object result = command.ExecuteScalar(); Console.WriteLine("Get tables count result \"{0}\"", result); return Convert.ToInt32(result); } } }