コード例 #1
0
        private TacContext GetDbContext()
        {
            var temp = CallContext.GetData(GlobalConfig.DataSink.EF_DB_CONTEXT) as TacContext;

            if (temp == null)
            {
                temp = new TacContext();
                CallContext.SetData(GlobalConfig.DataSink.EF_DB_CONTEXT, temp);
            }
            return(temp);
        }
コード例 #2
0
ファイル: RepositoryFactory.cs プロジェクト: taccisum/tac
        public RepositoryFactory()
        {
            //建立线程内唯一的db context,减少不必要的资源开销
            var temp = CallContext.GetData(GlobalConfig.DataSink.EF_DB_CONTEXT) as TacContext;

            if (temp == null)
            {
                temp = new TacContext();
                CallContext.SetData(GlobalConfig.DataSink.EF_DB_CONTEXT, temp);
            }
            _context = temp;

            _units = new Dictionary <string, object>();
        }
コード例 #3
0
ファイル: GenericRepository.cs プロジェクト: taccisum/tac
 public GenericRepository(TacContext context)
 {
     db    = context;
     dbSet = db.Set <T>();
 }
コード例 #4
0
ファイル: GenericRepository.cs プロジェクト: taccisum/tac
 public GenericRepository()
 {
     db    = new TacContext();
     dbSet = db.Set <T>();
 }