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


C# ConnectionFactory.ConnectionString方法代码示例

本文整理汇总了C#中ConnectionFactory.ConnectionString方法的典型用法代码示例。如果您正苦于以下问题:C# ConnectionFactory.ConnectionString方法的具体用法?C# ConnectionFactory.ConnectionString怎么用?C# ConnectionFactory.ConnectionString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConnectionFactory的用法示例。


在下文中一共展示了ConnectionFactory.ConnectionString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: return_standard_connection_string_using_trustedconnection

        public void return_standard_connection_string_using_trustedconnection()
        {
            // Arrange
            InstallerConfig config = new InstallerConfig();
            config.Database.DataSource = @"kingwilder-pc\sqlserver";
            config.Database.InitialCatalog = "BloggerApp";
            config.Database.UseTrustedConnection = true;

            ConnectionFactory factory = new ConnectionFactory(config);

            // Act
            var actual = factory.ConnectionString();
            var expected = string.Format("Data Source={0};Initial Catalog={1};Integrated Security=True", config.Database.DataSource, config.Database.InitialCatalog);

            // Assert
            Assert.AreEqual(expected, actual);
        }
开发者ID:aknuds1,项目名称:MvcInstaller,代码行数:17,代码来源:ConnectionFactoryTests.cs

示例2: return_entityframework_connection_using_trustedconnection

        public void return_entityframework_connection_using_trustedconnection()
        {
            // Arrange
            InstallerConfig config = new InstallerConfig();
            config.Database.DataSource = @"kingwilder-pc\sqlserver";
            config.Database.InitialCatalog = "BloggerApp";
            config.Database.UseTrustedConnection = true;
            config.Database.EntityFrameworkEntitiesName = "BloggerEntities";

            ConnectionFactory factory = new ConnectionFactory(config);

            // Act
            var actual = factory.ConnectionString();
            var expected = @"metadata=res://*/Models.BloggerEntities.csdl|res://*/Models.BloggerEntities.ssdl|res://*/Models.BloggerEntities.msl;provider=System.Data.SqlClient;provider connection string=""Data Source=kingwilder-pc\sqlserver;Initial Catalog=BloggerApp;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework""";

            // Assert
            Assert.AreEqual(expected, actual);
        }
开发者ID:aknuds1,项目名称:MvcInstaller,代码行数:18,代码来源:ConnectionFactoryTests.cs

示例3: return_standard_connection_string_with_credentials

        public void return_standard_connection_string_with_credentials()
        {
            // Arrange
            InstallerConfig config = new InstallerConfig();
            config.Database.DataSource = @"kingwilder-pc\sqlserver";
            config.Database.InitialCatalog = "BloggerApp";
            config.Database.UseTrustedConnection = false;
            config.Database.UserName = "dbadminuser";
            config.Database.Password = "dbadminpassword";

            ConnectionFactory factory = new ConnectionFactory(config);

            // Act
            var actual = factory.ConnectionString();
            var expected = string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3}", config.Database.DataSource, config.Database.InitialCatalog, config.Database.UserName, config.Database.Password);

            // Assert
            Assert.AreEqual(expected, actual);
        }
开发者ID:aknuds1,项目名称:MvcInstaller,代码行数:19,代码来源:ConnectionFactoryTests.cs


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