diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs index 7dfb991767..4ca549900f 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs @@ -18,13 +18,13 @@ namespace Umbraco.Core.Persistence.Repositories private const string NodeObjectType = "C66BA18E-EAF3-4CFF-8A22-41B16D66A972"; private readonly IContentTypeRepository _contentTypeRepository; - public ContentRepository(IUnitOfWork work, IContentTypeRepository contentTypeRepository) + public ContentRepository(IUnitOfWork work, IContentTypeRepository contentTypeRepository) : base(work) { _contentTypeRepository = contentTypeRepository; } - internal ContentRepository(IUnitOfWork work, IContentTypeRepository contentTypeRepository, IRepositoryCacheProvider registry) + internal ContentRepository(IUnitOfWork work, IContentTypeRepository contentTypeRepository, IRepositoryCacheProvider registry) : base(work, registry) { _contentTypeRepository = contentTypeRepository; diff --git a/src/Umbraco.Core/Persistence/Repositories/IRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IRepository.cs index e8902ebe5c..9f1888fece 100644 --- a/src/Umbraco.Core/Persistence/Repositories/IRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/IRepository.cs @@ -62,6 +62,6 @@ namespace Umbraco.Core.Persistence.Repositories /// Sets the Unit Of Work for the Repository /// /// - void SetUnitOfWork(IUnitOfWork work); + void SetUnitOfWork(IUnitOfWork work); } } \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Repositories/Repository.cs b/src/Umbraco.Core/Persistence/Repositories/Repository.cs index 1747a482a9..8e4084adb6 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Repository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Repository.cs @@ -12,23 +12,24 @@ namespace Umbraco.Core.Persistence.Repositories /// Represent an abstract Repository, which is the base of the Repository implementations /// /// - internal abstract class Repository : IDisposable, IRepository where TEntity : class, IAggregateRoot + internal abstract class Repository : IDisposable, + IRepository where TEntity : class, IAggregateRoot { - private IUnitOfWork _work; + private IUnitOfWork _work; private readonly IRepositoryCacheProvider _cache; - protected Repository(IUnitOfWork work) + protected Repository(IUnitOfWork work) : this(work, RuntimeCacheProvider.Current) { } - internal Repository(IUnitOfWork work, IRepositoryCacheProvider cache) + internal Repository(IUnitOfWork work, IRepositoryCacheProvider cache) { _work = work; _cache = cache; } - internal IUnitOfWork UnitOfWork + internal IUnitOfWork UnitOfWork { get { return _work; } } @@ -127,9 +128,9 @@ namespace Umbraco.Core.Persistence.Repositories return PerformCount(query); } - public void SetUnitOfWork(IUnitOfWork work) + public void SetUnitOfWork(IUnitOfWork work) { - _work = work; + _work = work as IUnitOfWork; } public virtual void Dispose() diff --git a/src/Umbraco.Core/Persistence/UnitOfWork/IUnitOfWork.cs b/src/Umbraco.Core/Persistence/UnitOfWork/IUnitOfWork.cs index 1f707f84e1..326c561b65 100644 --- a/src/Umbraco.Core/Persistence/UnitOfWork/IUnitOfWork.cs +++ b/src/Umbraco.Core/Persistence/UnitOfWork/IUnitOfWork.cs @@ -2,9 +2,9 @@ namespace Umbraco.Core.Persistence.UnitOfWork { - public interface IUnitOfWork : IDisposable + public interface IUnitOfWork : IDisposable { void Commit(); - Database Storage { get; } //TODO consider replacing 'Database' with a datastorage adapter, so there is no direct dependency on PetaPoco + T Storage { get; } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/UnitOfWork/IUnitOfWorkProvider.cs b/src/Umbraco.Core/Persistence/UnitOfWork/IUnitOfWorkProvider.cs index ee3404e8f2..d9bcd25cdf 100644 --- a/src/Umbraco.Core/Persistence/UnitOfWork/IUnitOfWorkProvider.cs +++ b/src/Umbraco.Core/Persistence/UnitOfWork/IUnitOfWorkProvider.cs @@ -1,7 +1,7 @@ namespace Umbraco.Core.Persistence.UnitOfWork { - public interface IUnitOfWorkProvider + public interface IUnitOfWorkProvider { - IUnitOfWork GetUnitOfWork(); + IUnitOfWork GetUnitOfWork(); } } \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/UnitOfWork/PetaPocoUnitOfWork.cs b/src/Umbraco.Core/Persistence/UnitOfWork/PetaPocoUnitOfWork.cs new file mode 100644 index 0000000000..39bd8dfcee --- /dev/null +++ b/src/Umbraco.Core/Persistence/UnitOfWork/PetaPocoUnitOfWork.cs @@ -0,0 +1,29 @@ +namespace Umbraco.Core.Persistence.UnitOfWork +{ + internal class PetaPocoUnitOfWork : IUnitOfWork + { + private readonly Transaction _petaTransaction; + private readonly Database _storage; + + public PetaPocoUnitOfWork() + { + _storage = new Database(@"server=.\SQLEXPRESS;database=UmbracoPOC-Site;user id=umbraco;password=umbraco", "System.Data.SqlClient"); + _petaTransaction = new Transaction(_storage); + } + + public void Dispose() + { + _petaTransaction.Dispose(); + } + + public void Commit() + { + _petaTransaction.Complete(); + } + + public Database Storage + { + get { return _storage; } + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/UnitOfWork/PetaPocoUnitOfWorkProvider.cs b/src/Umbraco.Core/Persistence/UnitOfWork/PetaPocoUnitOfWorkProvider.cs new file mode 100644 index 0000000000..87babcbc44 --- /dev/null +++ b/src/Umbraco.Core/Persistence/UnitOfWork/PetaPocoUnitOfWorkProvider.cs @@ -0,0 +1,10 @@ +namespace Umbraco.Core.Persistence.UnitOfWork +{ + internal class PetaPocoUnitOfWorkProvider : IUnitOfWorkProvider + { + public IUnitOfWork GetUnitOfWork() + { + return new PetaPocoUnitOfWork(); + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 273d16a080..09b94fc018 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -99,6 +99,8 @@ + + diff --git a/src/umbraco.sln b/src/umbraco.sln index b10a9c82db..e24d8c5269 100644 --- a/src/umbraco.sln +++ b/src/umbraco.sln @@ -52,8 +52,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "umbraco.MacroEngines", "umb EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "umbraco.MacroEngines.Iron", "umbraco.MacroEngines.Iron\umbraco.MacroEngines.Iron.csproj", "{98CBA7E2-1B62-497C-8AA3-B868704068D7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.LegacyTests", "..\test\umbraco.Test\Umbraco.LegacyTests.csproj", "{6277C9FB-3A9A-4537-AA86-82DA9B2527FD}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{B5BD12C1-A454-435E-8A46-FF4A364C0382}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Core", "Umbraco.Core\Umbraco.Core.csproj", "{31785BC3-256C-4613-B2F5-A1B0BDDED8C1}" @@ -123,10 +121,6 @@ Global {98CBA7E2-1B62-497C-8AA3-B868704068D7}.Debug|Any CPU.Build.0 = Debug|Any CPU {98CBA7E2-1B62-497C-8AA3-B868704068D7}.Release|Any CPU.ActiveCfg = Release|Any CPU {98CBA7E2-1B62-497C-8AA3-B868704068D7}.Release|Any CPU.Build.0 = Release|Any CPU - {6277C9FB-3A9A-4537-AA86-82DA9B2527FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6277C9FB-3A9A-4537-AA86-82DA9B2527FD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6277C9FB-3A9A-4537-AA86-82DA9B2527FD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6277C9FB-3A9A-4537-AA86-82DA9B2527FD}.Release|Any CPU.Build.0 = Release|Any CPU {31785BC3-256C-4613-B2F5-A1B0BDDED8C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {31785BC3-256C-4613-B2F5-A1B0BDDED8C1}.Debug|Any CPU.Build.0 = Debug|Any CPU {31785BC3-256C-4613-B2F5-A1B0BDDED8C1}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -144,7 +138,6 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {6277C9FB-3A9A-4537-AA86-82DA9B2527FD} = {B5BD12C1-A454-435E-8A46-FF4A364C0382} {5D3B8245-ADA6-453F-A008-50ED04BFE770} = {B5BD12C1-A454-435E-8A46-FF4A364C0382} EndGlobalSection EndGlobal