public UpdateTableTests() { _sb = new StringBuilder(); _w = new ExpressionWriter(_sb,new SqlServerBuilderHelper()); _db = Setup.GetDb(); _builder = new UpdateTableBuilder<Post>(_db); }
public AlterTableColumnTests() { _db = Setup.GetDb(); _writer = new SqlServerDDLWriter(_db); _table = new ModifyTableBuilder(_db, _writer, "users"); SetupTestTable(); }
public DbConnection Create(string cnxString) { var db = new SqlFuConnection(Provider, cnxString ?? _cnx, _config); db.Open(); return(db); }
public void sqlfu_using_another_dbconnection() { var conex = new SqlConnection(Setup.Connex); using (var db = new SqlFuConnection(conex, DbEngine.SqlServer)) { Assert.True(db.TableExists<Post>()); } }
public override void Commit() { if (_db != null) { _db.Commit(); _db = null; } else { throw new InvalidOperationException("Transaction already finished"); } }
public static DbConnection OpenConnection(IDbProvider provider, string connectionString) { provider.MustNotBeNull(); if (connectionString == null) { throw new InvalidOperationException( "I need a connection! Either set SqlFuFactory.Config.Providers.ConnectionString method or define a connection in config file. If there are more than one connection defined, set SqlFuFactory.Config.Providers.ConnectionString"); } var sql = new SqlFuConnection(provider, connectionString); sql.Open(); return(sql); }
public static async Task <DbConnection> OpenConnectionAsync(IDbProvider provider, string connectionString, CancellationToken cancel) { provider.MustNotBeNull(); if (connectionString == null) { throw new InvalidOperationException( "I need a connection! Either set SqlFuFactory.Config.Providers.ConnectionString method or define a connection in config file. If there are more than one connection defined, set SqlFuFactory.Config.Providers.ConnectionString"); } var sql = new SqlFuConnection(provider, connectionString); await sql.OpenAsync(cancel).ConfigureAwait(false); return(sql); }
public DbConnection Create(DbConnection db = null) { SqlFuConnection cnx; if (db != null) { cnx = new SqlFuConnection(Provider, db, _config); } else { cnx = new SqlFuConnection(Provider, _cnx, _config); } cnx.Open(); return(cnx); }
public static SqlFuConnection GetDb(bool noLog = false,DbEngine engine=DbEngine.SqlServer) { var cnx = Connex; switch(engine) { case DbEngine.SQLite: DirectoryInfo dd = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); var f = dd.Parent.Parent.FullName; cnx = string.Format(SqliteConnex, Path.Combine(f, "testdb.db")); //cnx = SqliteConnex; break; case DbEngine.MySql: cnx = MysqlConnex; break; case DbEngine.PostgreSQL: cnx = PostgresConnex; break; } var d = new SqlFuConnection(cnx, engine); return d; }
public MyTransactionWrapper(SqlFuConnection db) { _db = db; }
public override void Rollback() { _db.Rollback(); _db = null; }
public SqlFuTests() { _db = new SqlFuConnection(Config.Connex, DbEngine.SqlServer); }
public CommonDatabaseToolsTests() { Db = Setup.GetDb(engine:Engine); SetupTable(); }
public CreateTableTests() { db = Db; _ddl = new SqlServerDDLWriter(db); db.DatabaseTools.DropTable("test"); }
public QueryTests() { _db = Config.GetDb(); }
public ComplexTypeMapper() { _db = Config.GetDb(); }
public EscapeSqlTests() { _db = Config.GetDb(); }
//public static void Benchmark(Stopwatch timer,Action bench,string name,bool warm=false) //{ // var nr = warm ? WarmUp : Iterations; // timer.Restart(); // for (int i = 0; i < nr; i++) bench(); // timer.Stop(); // if (!warm) Console.WriteLine("{0} took {1} ms",name,timer.Elapsed.TotalMilliseconds); //} public static SqlFuConnection GetDb() { var d = new SqlFuConnection(Connex, DbEngine.SqlServer); return d; }
public CommonAlterTableTests() { Db = Setup.GetDb(engine: Engine); SetupTable(); Table = Db.DatabaseTools.GetAlterTableBuilder(TableName); }
public CommonCreateTableTests() { Db = Setup.GetDb(engine: Engine); SetupTable(); }
public QueriesWithMultiPocoMapper() { _db = Config.GetDb(); }
public HelpersTests() { _db = Config.GetDb(); Config.EnsurePosts(); }
public DbExtrensionsMethodsTests() { _db = Config.GetDb(); Config.EnsurePosts(); }
public AutomaticMigrationTests() { _db = Setup.GetDb(); }