ForEach(repository =>
{
var objectContextServiceType = typeof(BaseObjectContext<>)
.MakeGenericType(repository.ObjectContextType);
container.RegisterType(objectContextServiceType,
new PerExecutionContextLifetimeManager());
var repositoryServiceType = typeof(IRepository<>)
.MakeGenericType(repository.DomainType);
var repositoryImplementation = typeof(EntityRepository<,>)
.MakeGenericType(repository.DomainType,
repository.ObjectContextType);
container.RegisterType(repositoryServiceType,
repositoryImplementation,
new TransientLifetimeManager());
})
当Unity尝试解析EntityContext时,我收到错误:无法消除实体上下文创建的歧义