Esempio n. 1
0
        /// <summary>
        /// 获得数据访问上下文
        /// </summary>
        /// <returns></returns>
        public HiDataContext GetDataContext()
        {
            HiDataContext context = null;

            if (HttpContext.Current.Items.Contains(_dataContextKey))
            {
                context = (HiDataContext)HttpContext.Current.Items[_dataContextKey];
            }
            return(context);
        }
Esempio n. 2
0
 /// <summary>
 /// 存储数据访问上下文
 /// </summary>
 /// <param name="context"></param>
 public void Store(HiDataContext context)
 {
     if (HttpContext.Current.Items.Contains(_dataContextKey))
     {
         HttpContext.Current.Items[_dataContextKey] = context;
     }
     else
     {
         HttpContext.Current.Items.Add(_dataContextKey, context);
     }
 }
        public HiDataContext GetDataContext()
        {
            HiDataContext libraryDataContext = null;

            if (_libraryDataContexts.Contains(GetThreadName()))
            {
                libraryDataContext = (HiDataContext)_libraryDataContexts[GetThreadName()];
            }

            return(libraryDataContext);
        }
 public void Store(HiDataContext context)
 {
     if (_libraryDataContexts.Contains(GetThreadName()))
     {
         _libraryDataContexts[GetThreadName()] = context;
     }
     else
     {
         _libraryDataContexts.Add(GetThreadName(), context);
     }
 }
Esempio n. 5
0
        public static HiDataContext GetDataContext()
        {
            IDataContextStorageContainer _dataContextStorageContainer = DataContextStorageFactory.CreateStorageContainer();

            HiDataContext dataContext = _dataContextStorageContainer.GetDataContext();

            if (dataContext == null)
            {
                dataContext = new HiDataContext();
                _dataContextStorageContainer.Store(dataContext);
            }

            return(dataContext);
        }