New implementation of IDatabaseFactory, allows setting the DatabaseContext.Current at runtime
with a custom IDatabaseFactory (mostly for testing). Changes AuditTrail to internal so the public way is just with the 'Audit' class. Fixed ThreadSafetyServiceTests which was failing with the new AuditTrail stuff because of the Database instances, this is not solved with the new PerThreadDatabaseFactory for the unit test. Created new 'UmbracoDatabase' object which inherits from the PetaPoco one so that we can future proof the implementation as we might want some custom logic on there. Now the IDatabaseFactory returns an UmbracoDatabase instead of just Database.
This commit is contained in:
32
src/Umbraco.Core/Persistence/UmbracoDatabase.cs
Normal file
32
src/Umbraco.Core/Persistence/UmbracoDatabase.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace Umbraco.Core.Persistence
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Umbraco implementation of the PetaPoco Database object
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Currently this object exists for 'future proofing' our implementation. By having our own inheritied implementation we
|
||||
/// can then override any additional execution (such as additional loggging, functionality, etc...) that we need to without breaking compatibility since we'll always be exposing
|
||||
/// this object instead of the base PetaPoco database object.
|
||||
/// </remarks>
|
||||
public class UmbracoDatabase : Database
|
||||
{
|
||||
public UmbracoDatabase(IDbConnection connection) : base(connection)
|
||||
{
|
||||
}
|
||||
|
||||
public UmbracoDatabase(string connectionString, string providerName) : base(connectionString, providerName)
|
||||
{
|
||||
}
|
||||
|
||||
public UmbracoDatabase(string connectionString, DbProviderFactory provider) : base(connectionString, provider)
|
||||
{
|
||||
}
|
||||
|
||||
public UmbracoDatabase(string connectionStringName) : base(connectionStringName)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user