Reducing the usage of the DatabaseFactory

This commit is contained in:
Morten Christensen
2012-11-26 17:20:58 -01:00
parent 7140922e7a
commit e5ec9eb06f
5 changed files with 9 additions and 5 deletions

View File

@@ -16,7 +16,7 @@ namespace Umbraco.Core.Auditing
/// <param name="comment">Audit comment</param>
public void WriteEntry(int objectId, int userId, DateTime date, string header, string comment)
{
DatabaseFactory.Current.Database.Insert(new LogDto
DatabaseContext.Current.Database.Insert(new LogDto
{
Comment = comment,
Datestamp = date,

View File

@@ -6,8 +6,12 @@ namespace Umbraco.Core.Persistence
{
/// <summary>
/// Provides access to the PetaPoco database as Singleton, so the database is created once in app lifetime.
/// This is necessary for transactions to work properly
/// This is necessary for transactions to work properly.
/// </summary>
/// <remarks>
/// Because the Database is created static, the configuration has to be checked and set in
/// another class, which is where the DatabaseContext comes in.
/// </remarks>
public sealed class DatabaseFactory
{
#region Singleton

View File

@@ -25,7 +25,7 @@ namespace Umbraco.Core.Persistence.Repositories
protected Database Database
{
get { return DatabaseFactory.Current.Database; }
get { return DatabaseContext.Current.Database; }
}
#region Abstract Methods

View File

@@ -47,7 +47,7 @@ namespace Umbraco.Core.Services
if(HttpRuntime.Cache[cacheKey] == null)
{
userId =
DatabaseFactory.Current.Database.ExecuteScalar<int>(
DatabaseContext.Current.Database.ExecuteScalar<int>(
"select userID from umbracoUserLogins where contextID = @ContextId",
new {ContextId = new Guid(contextId)});

View File

@@ -112,7 +112,7 @@ namespace Umbraco.Tests.CodeFirst.Definitions
Value = value
};
DatabaseFactory.Current.Database.Insert(poco);
DatabaseContext.Current.Database.Insert(poco);
}
/// <summary>