我有一个使用通用上下文的UnitOfWork。如何使用结构Map确定存储库决定使用的具体上下文?
public SomeRepository(IUnitOfWork unitOfWorkSomeContext)
{
_uowContext = unitOfWork.Context as ISomeContext;
}
public class UnitOfWork: IUnitOfWork
{
private readonly IContext _context;
public UnitOfWork(IContext context)
{
context.Configuration.AutoDetectChangesEnabled = false;
context.Configuration.ProxyCreationEnabled = false;
context.Configuration.LazyLoadingEnabled = false;
_context = context;
}
public int Save()
{
return _context.SaveChanges();
}
public IContext Context
{
get { return _context; }
}
public void Dispose()
{
_context.Dispose();
}
}
谢谢,
道格