本文整理汇总了C#中DatabaseProviderFactory类的典型用法代码示例。如果您正苦于以下问题:C# DatabaseProviderFactory类的具体用法?C# DatabaseProviderFactory怎么用?C# DatabaseProviderFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseProviderFactory类属于命名空间,在下文中一共展示了DatabaseProviderFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
DatabaseProviderFactory factory = new DatabaseProviderFactory(TestConfigurationSource.CreateConfigurationSource());
db = factory.CreateDefault();
CompleteSetup(db);
}
示例2: AssertOracleClientIsInstalled
public static void AssertOracleClientIsInstalled()
{
if (!oracleClientIsInstalled.HasValue)
{
try
{
var factory = new DatabaseProviderFactory(OracleTestConfigurationSource.CreateConfigurationSource());
var db = factory.Create("OracleTest");
var conn = db.CreateConnection();
conn.Open();
conn.Close();
}
catch (Exception ex)
{
if (ex.Message != null && ex.Message.Contains("System.Data.OracleClient")
&& ex.Message.Contains("8.1.7"))
{
oracleClientIsInstalled = false;
oracleClientNotInstalledErrorMessage = ex.Message;
}
else
{
throw;
}
}
}
if (oracleClientIsInstalled.HasValue && oracleClientIsInstalled.Value == false)
{
Assert.Inconclusive(oracleClientNotInstalledErrorMessage);
}
}
示例3: SetUp
public void SetUp()
{
DatabaseProviderFactory factory = new DatabaseProviderFactory(new TestConfigurationContext());
this.db = factory.CreateDatabase("OracleTest");
this.sqlCommand = "Select count(*) from region";
this.command = this.db.GetSqlStringCommandWrapper(this.sqlCommand);
}
示例4: UseParameterCachingWithPersistSecurityInfoFalse
public void UseParameterCachingWithPersistSecurityInfoFalse()
{
try
{
DeleteUser();
CreateUser();
DatabaseProviderFactory factory = new DatabaseProviderFactory(new TestConfigurationContext());
Database dbsec = factory.CreateDatabase("NorthwindPersistFalse");
connection = dbsec.GetConnection();
connection.Open();
DBCommandWrapper storedProc1 = dbsec.GetStoredProcCommandWrapper("CustOrdersOrders", "ALFKI");
storedProc1.Command.Connection = connection;
TestCache testCache = new TestCache();
testCache.FillParameters(storedProc1, '@');
DBCommandWrapper storedProc2 = dbsec.GetStoredProcCommandWrapper("CustOrdersOrders", "ALFKI");
storedProc2.Command.Connection = connection;
testCache.FillParameters(storedProc2, '@');
Assert.IsTrue(testCache.CacheUsed);
}
finally
{
DeleteUser();
}
}
示例5: SetUp
public void SetUp()
{
DatabaseProviderFactory factory = new DatabaseProviderFactory(new Db2TestConfigurationContext());
this.db = factory.CreateDatabase("DB2Test");
this.dataSet = new DataSet();
this.command = this.db.GetSqlStringCommandWrapper(this.sqlQuery);
}
示例6: SetUp
public void SetUp()
{
EnvironmentHelper.AssertOracleClientIsInstalled();
var factory = new DatabaseProviderFactory(OracleTestConfigurationSource.CreateConfigurationSource());
db = factory.Create("OracleTest");
CompleteSetup(db);
}
示例7: SetUp
public void SetUp()
{
EnvironmentHelper.AssertOracleClientIsInstalled();
DatabaseProviderFactory factory = new DatabaseProviderFactory(OracleTestConfigurationSource.CreateConfigurationSource());
db = factory.Create("OracleTest");
CreateTableWithGuidAndBinary();
}
示例8: SkipsConnectionStringsWithoutProviderNamesOrWithProviderNamesWhichDoNotMapToAProviderFactory
public void SkipsConnectionStringsWithoutProviderNamesOrWithProviderNamesWhichDoNotMapToAProviderFactory()
{
DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();
ConnectionStringsSection section = new ConnectionStringsSection();
section.ConnectionStrings.Add(new ConnectionStringSettings("cs1", "cs1", "System.Data.SqlClient"));
section.ConnectionStrings.Add(new ConnectionStringSettings("cs2", "cs2"));
section.ConnectionStrings.Add(new ConnectionStringSettings("cs3", "cs3", "a bogus provider name"));
section.ConnectionStrings.Add(new ConnectionStringSettings("cs4", "cs4", "System.Data.SqlClient"));
configurationSource.Add("connectionStrings", section);
var factory = new DatabaseProviderFactory(configurationSource.GetSection);
Assert.AreEqual("cs1", factory.Create("cs1").ConnectionString);
Assert.AreEqual("cs4", factory.Create("cs4").ConnectionString);
try
{
factory.Create("cs2");
Assert.Fail("should have thrown");
}
catch (InvalidOperationException)
{
// expected, connection string is ignored
}
try
{
factory.Create("cs3");
Assert.Fail("should have thrown");
}
catch (InvalidOperationException)
{
// expected, connection string is ignored
}
}
示例9: Setup
public void Setup()
{
var factory = new DatabaseProviderFactory(TestConfigurationSource.CreateConfigurationSource());
var db = factory.CreateDefault();
connection = db.CreateConnection();
connection.Open();
}
示例10: CallingTwiceReturnsDifferenceDatabaseInstances
public void CallingTwiceReturnsDifferenceDatabaseInstances()
{
DatabaseProviderFactory factory = new DatabaseProviderFactory(TestConfigurationSource.CreateConfigurationSource());
Database firstDb = factory.Create("NewDatabase");
Database secondDb = factory.Create("NewDatabase");
Assert.AreNotSame(firstDb, secondDb);
}
示例11: CallingTwiceReturnsDifferenceDatabaseInstances
public void CallingTwiceReturnsDifferenceDatabaseInstances()
{
DatabaseProviderFactory factory = new DatabaseProviderFactory(new TestConfigurationContext());
Database firstDb = factory.CreateDatabase("NewDatabase");
Database secondDb = factory.CreateDatabase("NewDatabase");
Assert.IsFalse(firstDb == secondDb);
}
示例12: SetUp
public void SetUp()
{
DatabaseProviderFactory factory = new DatabaseProviderFactory(TestConfigurationSource.CreateConfigurationSource());
db = factory.CreateDefault();
DbCommand command = db.GetSqlStringCommand("Select count(*) from region");
baseFixture = new ExecuteScalarFixture(db, command);
}
示例13: SetUp
public void SetUp()
{
DatabaseProviderFactory factory = new DatabaseProviderFactory(new Db2TestConfigurationContext());
this.db = factory.CreateDatabase("DB2Test");
this.queryString = "Select * from Region";
this.insertString = "Insert into Region values (99, 'Midwest')";
this.insertCommand = this.db.GetSqlStringCommandWrapper(this.insertString);
this.queryCommand = this.db.GetSqlStringCommandWrapper(this.queryString);
}
示例14: SetUp
public void SetUp()
{
EnvironmentHelper.AssertOracleClientIsInstalled();
DatabaseProviderFactory factory = new DatabaseProviderFactory(OracleTestConfigurationSource.CreateConfigurationSource());
db = factory.Create("OracleTest");
DbCommand command = db.GetSqlStringCommand("Select count(*) from region");
baseFixture = new ExecuteScalarFixture(db, command);
}
示例15: CanCreateSqlDatabaseFromFactory
public void CanCreateSqlDatabaseFromFactory()
{
var factory = new DatabaseProviderFactory(new SystemConfigurationSource(false).GetSection);
Database createdObject = factory.Create("Service_Dflt");
Assert.IsNotNull(createdObject);
Assert.AreEqual(@"server=(localdb)\v11.0;database=northwind;integrated security=true;",
createdObject.ConnectionStringWithoutCredentials);
}