当前位置: 首页>>代码示例>>C#>>正文


C# DatabaseProviderFactory类代码示例

本文整理汇总了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);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:7,代码来源:SqlStoredProcedureCreatingFixture.cs

示例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);
            }
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:32,代码来源:EnvironmentHelper.cs

示例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);
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:7,代码来源:OracleExecuteScalarFixture.cs

示例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();
            }
        }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:28,代码来源:SqlParameterDiscoveryFixture.cs

示例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);
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:7,代码来源:DB2DataAccessTestsFixture.cs

示例6: SetUp

 public void SetUp()
 {
     EnvironmentHelper.AssertOracleClientIsInstalled();
     var factory = new DatabaseProviderFactory(OracleTestConfigurationSource.CreateConfigurationSource());
     db = factory.Create("OracleTest");
     CompleteSetup(db);
 }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:7,代码来源:OracleStoredProcedureCreatingFixture.cs

示例7: SetUp

 public void SetUp()
 {
     EnvironmentHelper.AssertOracleClientIsInstalled();
     DatabaseProviderFactory factory = new DatabaseProviderFactory(OracleTestConfigurationSource.CreateConfigurationSource());
     db = factory.Create("OracleTest");
     CreateTableWithGuidAndBinary();
 }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:7,代码来源:OracleBugFixingRegressionFixture.cs

示例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
            }
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:34,代码来源:DatabaseProviderFactoryFixture.cs

示例9: Setup

 public void Setup()
 {
     var factory = new DatabaseProviderFactory(TestConfigurationSource.CreateConfigurationSource());
     var db = factory.CreateDefault();
     connection = db.CreateConnection();
     connection.Open();
 }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:7,代码来源:DatabaseConnectionWrapperFixture.cs

示例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);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:8,代码来源:DatabaseFactoryOldFixture.cs

示例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);
        }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:8,代码来源:DatabaseFactoryFixture.cs

示例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);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:8,代码来源:SqlExecuteScalarFixture.cs

示例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);
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:9,代码来源:DB2ExecuteReaderFixture.cs

示例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);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:9,代码来源:OracleExecuteScalarFixture.cs

示例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);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:9,代码来源:DatabaseProviderFactoryFixture.cs


注:本文中的DatabaseProviderFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。