本文整理汇总了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);
}
示例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);
}
示例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);
}