Minor adjustment to the ctor's of DefaultDatabaseFactory and PetaPocoUnitOfWorkProvider that clarifies the use of either ConnectionStringName or a custom ConnectionString+ProviderName.
This commit is contained in:
@@ -13,7 +13,8 @@ namespace Umbraco.Core.Persistence
|
||||
/// </remarks>
|
||||
internal class DefaultDatabaseFactory : DisposableObject, IDatabaseFactory
|
||||
{
|
||||
private readonly string _connectionString;
|
||||
private readonly string _connectionStringName;
|
||||
private readonly string _connectionString;
|
||||
private readonly string _providerName;
|
||||
private static volatile UmbracoDatabase _globalInstance = null;
|
||||
private static readonly object Locker = new object();
|
||||
@@ -29,18 +30,18 @@ namespace Umbraco.Core.Persistence
|
||||
/// <summary>
|
||||
/// Constructor accepting custom connection string
|
||||
/// </summary>
|
||||
/// <param name="connectionString"></param>
|
||||
public DefaultDatabaseFactory(string connectionString)
|
||||
/// <param name="connectionStringName">Name of the connection string in web.config</param>
|
||||
public DefaultDatabaseFactory(string connectionStringName)
|
||||
{
|
||||
Mandate.ParameterNotNullOrEmpty(connectionString, "connectionString");
|
||||
_connectionString = connectionString;
|
||||
Mandate.ParameterNotNullOrEmpty(connectionStringName, "connectionStringName");
|
||||
_connectionStringName = connectionStringName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor accepting custom connectino string and provider name
|
||||
/// </summary>
|
||||
/// <param name="connectionString"></param>
|
||||
/// <param name="providerName"></param>
|
||||
/// <param name="connectionString">Connection String to use with Database</param>
|
||||
/// <param name="providerName">Database Provider for the Connection String</param>
|
||||
public DefaultDatabaseFactory(string connectionString, string providerName)
|
||||
{
|
||||
Mandate.ParameterNotNullOrEmpty(connectionString, "connectionString");
|
||||
@@ -61,9 +62,9 @@ namespace Umbraco.Core.Persistence
|
||||
//double check
|
||||
if (_globalInstance == null)
|
||||
{
|
||||
_globalInstance = string.IsNullOrEmpty(_providerName)
|
||||
? new UmbracoDatabase(_connectionString)
|
||||
: new UmbracoDatabase(_connectionString, _providerName);
|
||||
_globalInstance = string.IsNullOrEmpty(_providerName) == false && string.IsNullOrEmpty(_providerName) == false
|
||||
? new UmbracoDatabase(_connectionString, _providerName)
|
||||
: new UmbracoDatabase(_connectionStringName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,9 +75,9 @@ namespace Umbraco.Core.Persistence
|
||||
if (!HttpContext.Current.Items.Contains(typeof(DefaultDatabaseFactory)))
|
||||
{
|
||||
HttpContext.Current.Items.Add(typeof (DefaultDatabaseFactory),
|
||||
string.IsNullOrEmpty(_providerName)
|
||||
? new UmbracoDatabase(_connectionString)
|
||||
: new UmbracoDatabase(_connectionString, _providerName));
|
||||
string.IsNullOrEmpty(_providerName) == false && string.IsNullOrEmpty(_providerName) == false
|
||||
? new UmbracoDatabase(_connectionString, _providerName)
|
||||
: new UmbracoDatabase(_connectionStringName));
|
||||
}
|
||||
return (UmbracoDatabase)HttpContext.Current.Items[typeof(DefaultDatabaseFactory)];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Persistence.UnitOfWork
|
||||
{
|
||||
@@ -19,6 +18,14 @@ namespace Umbraco.Core.Persistence.UnitOfWork
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor accepting custom connectino string and provider name
|
||||
/// </summary>
|
||||
/// <param name="connectionString">Connection String to use with Database</param>
|
||||
/// <param name="providerName">Database Provider for the Connection String</param>
|
||||
public PetaPocoUnitOfWorkProvider(string connectionString, string providerName) : this(new DefaultDatabaseFactory(connectionString, providerName))
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor accepting an IDatabaseFactory instance
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user