结构图UnitOfWork多个通用上下文EF

时间:2012-11-29 18:34:18

标签: entity-framework structuremap dbcontext unit-of-work bounded-contexts

我有一个使用通用上下文的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();
    }
}

谢谢,

道格

0 个答案:

没有答案