Changed all data services to create one repository type in the constructor instead of resolving
them in each method since they are only supposed to be using their single unit of work anyways (resolving will return the same repository anyways, but in some cases it might have been with a different UOW) Removed SetUnitOfWork method on IRepository as this is not needed. Removed the old implementation of RepositoryResolver and replaces it with the RepositoryInstanceResolver (but maintained the name of RepositoryResolver)
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
using Umbraco.Core.Persistence.UnitOfWork;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
@@ -49,7 +50,8 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
public static IProfile GetCreatorProfile(this IContent content)
|
||||
{
|
||||
var repository = RepositoryResolver.ResolveByType<IUserRepository>(null);
|
||||
var repository = RepositoryResolver.Current.Factory.CreateUserRepository(
|
||||
new PetaPocoUnitOfWork());
|
||||
return repository.GetProfileById(content.CreatorId);
|
||||
}
|
||||
|
||||
@@ -58,7 +60,8 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
public static IProfile GetWriterProfile(this IContent content)
|
||||
{
|
||||
var repository = RepositoryResolver.ResolveByType<IUserRepository>(null);
|
||||
var repository = RepositoryResolver.Current.Factory.CreateUserRepository(
|
||||
new PetaPocoUnitOfWork());
|
||||
return repository.GetProfileById(content.WriterId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user