public static IDatabase GetDatabase(EnumDatabaseType sTypeConnection, string sConnectionString) { IDatabase oReturnDatabase = null; switch (sTypeConnection) { case EnumDatabaseType.SqlServer: oReturnDatabase = new DatabaseSqlServer(sConnectionString); break; case EnumDatabaseType.Oracle: oReturnDatabase = new DatabaseOracle(sConnectionString); break; case EnumDatabaseType.MySQL: oReturnDatabase = new DatabaseMySQL(sConnectionString); break; case EnumDatabaseType.SQLite: oReturnDatabase = new DatabaseSQLite(sConnectionString); break; default: oReturnDatabase = null; break; } return(oReturnDatabase); }
public static IDatabase getDatabaseHelper(String databaseType , AdoTemplate template , string connectionString , String databaseName , string projectNamespace , string projectFolder , bool semaIsminiSorgulardaKullan , bool semaIsminiDizinlerdeKullan , bool dboSemaTablolariniAtla , bool sysTablolariniAtla ) { IDatabase helper = null; switch (databaseType) { case DatabaseType.SqlServer: helper = new DatabaseSqlServer(template, connectionString, databaseName, projectNamespace, projectFolder, "System.Data.SqlClient", semaIsminiSorgulardaKullan, semaIsminiDizinlerdeKullan, sysTablolariniAtla, null); break; case DatabaseType.Oracle: helper = new DatabaseOracle(template, connectionString, databaseName, projectNamespace, projectFolder, "System.Data.OracleClient", semaIsminiSorgulardaKullan, semaIsminiDizinlerdeKullan, sysTablolariniAtla, null); break; case DatabaseType.Sqlite: helper = new DatabaseSqlite(template, connectionString, databaseName, projectNamespace, projectFolder, "System.Data.SQLite", semaIsminiSorgulardaKullan, semaIsminiDizinlerdeKullan, sysTablolariniAtla, null); break; } return(helper); }
public void Test1() { string url = "Server=(localdb)\\MSSQLLocalDB;Integrated Security=true"; DatabaseSqlServer sqlserver = new DatabaseSqlServer(url); Database.Table table = sqlserver.OpenTable("test1"); sqlserver.Flush(null, () => { { ByteBuffer key = ByteBuffer.Allocate(); key.WriteInt(1); table.Remove(key); } { ByteBuffer key = ByteBuffer.Allocate(); key.WriteInt(2); table.Remove(key); } } ); Assert.AreEqual(0, table.Walk(PrintRecord)); sqlserver.Flush(null, () => { { ByteBuffer key = ByteBuffer.Allocate(); key.WriteInt(1); ByteBuffer value = ByteBuffer.Allocate(); value.WriteInt(1); table.Replace(key, value); } { ByteBuffer key = ByteBuffer.Allocate(); key.WriteInt(2); ByteBuffer value = ByteBuffer.Allocate(); value.WriteInt(2); table.Replace(key, value); } } ); { ByteBuffer key = ByteBuffer.Allocate(); key.WriteInt(1); ByteBuffer value = table.Find(key); Assert.IsNotNull(value); Assert.AreEqual(1, value.ReadInt()); Assert.IsTrue(value.ReadIndex == value.WriteIndex); } { ByteBuffer key = ByteBuffer.Allocate(); key.WriteInt(2); ByteBuffer value = table.Find(key); Assert.IsNotNull(value); Assert.AreEqual(2, value.ReadInt()); Assert.IsTrue(value.ReadIndex == value.WriteIndex); } Assert.AreEqual(2, table.Walk(PrintRecord)); }
private void testSqlServer(string connectionString, string databaseName) { connection = new SqlConnection(connectionString); connection.Open(); connection.Close(); template = new AdoTemplate(); template.Connection = connection; template.DbProviderName = "System.Data.SqlClient"; DatabaseHelper = new DatabaseSqlServer(template); }