Changes PetaPocoUnitOfWorkFactory to accept an IDatabaseFactory as ctor. Changes PetaPocoUnitOfWork to not dispose of the Database since

it will be shared with the current thread in order to support nested transactions and changes how the Transaction object is created
and used and then disposed of. Changes PetaPocoUnitOfWorkFactory to ensure that the UOW is
created with the shared Database instance. Fixes a method in UserService to ensure that the UOW is disposed since it wasn't using a repository.
This commit is contained in:
Shannon Deminick
2012-12-15 08:41:46 +05:00
parent f5bfb90b64
commit ad7aa66b0b
7 changed files with 226 additions and 177 deletions

View File

@@ -53,16 +53,18 @@ namespace Umbraco.Core.Services
if(HttpRuntime.Cache[cacheKey] == null)
{
var uow = _uowProvider.GetUnitOfWork();
userId =
uow.Database.ExecuteScalar<int>(
"select userID from umbracoUserLogins where contextID = @ContextId",
new {ContextId = new Guid(contextId)});
using (var uow = _uowProvider.GetUnitOfWork())
{
userId =
uow.Database.ExecuteScalar<int>(
"select userID from umbracoUserLogins where contextID = @ContextId",
new { ContextId = new Guid(contextId) });
HttpRuntime.Cache.Insert(cacheKey, userId,
null,
System.Web.Caching.Cache.NoAbsoluteExpiration,
new TimeSpan(0, (int)(Umbraco.Core.Configuration.GlobalSettings.TimeOutInMinutes / 10), 0));
HttpRuntime.Cache.Insert(cacheKey, userId,
null,
System.Web.Caching.Cache.NoAbsoluteExpiration,
new TimeSpan(0, (int)(Umbraco.Core.Configuration.GlobalSettings.TimeOutInMinutes / 10), 0));
}
}
else
{