コード例 #1
0
 public EFDbContext GetCurrentDbContext()
 {
     if (DbContextContainer == null)
     {
         return(null);
     }
     return(DbContextContainer.GetCurrentDbContext());
 }
コード例 #2
0
        private static DbContextContainer GetCurrentDbContext(IDbContextFactory factory)
        {
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }
            if (factory.DbContextContainer == null)
            {
                throw new Exception("没有配置CurrentDbContext");
            }
            DbContextContainer currentDbContext = factory.DbContextContainer as DbContextContainer;

            if (currentDbContext == null)
            {
                throw new Exception("Current DbContext没有继承CurrentDbContext");
            }
            return(currentDbContext);
        }