/// <summary> /// 获取线程上下文 /// </summary> /// <returns></returns> public ModelBaseContext GetDataContext() { ModelBaseContext libraryDataContext = null; if (_libraryDataContexts.Contains(GetThreadName())) { libraryDataContext = (ModelBaseContext)_libraryDataContexts[GetThreadName()]; } return(libraryDataContext); }
/// <summary> /// 执行缓存 /// </summary> /// <param name="libraryDataContext"></param> public void Store(ModelBaseContext libraryDataContext) { if (_libraryDataContexts.Contains(GetThreadName())) { _libraryDataContexts[GetThreadName()] = libraryDataContext; } else { _libraryDataContexts.Add(GetThreadName(), libraryDataContext); } }
/// <summary> /// 获取上下文 /// </summary> /// <returns></returns> public ModelBaseContext GetDataContext() { ModelBaseContext objectContext = null; if (Blog.Infrastructure.HttpExtenions.HttpContext.Current.Items.ContainsKey(_dataContextKey)) { objectContext = (ModelBaseContext)Blog.Infrastructure.HttpExtenions.HttpContext.Current.Items[_dataContextKey]; } return(objectContext); }
/// <summary> /// 获取缓存上下文 /// </summary> /// <param name="libraryDataContext"></param> public void Store(ModelBaseContext libraryDataContext) { if (Blog.Infrastructure.HttpExtenions.HttpContext.Current.Items.ContainsKey(_dataContextKey)) { Blog.Infrastructure.HttpExtenions.HttpContext.Current.Items[_dataContextKey] = libraryDataContext; } else { Blog.Infrastructure.HttpExtenions.HttpContext.Current.Items.Add(_dataContextKey, libraryDataContext); } }
/// <summary> /// 获取上下文 /// </summary> /// <returns></returns> public static ModelBaseContext GetDataContext() { IDataContextStorageContainer _dataContextStorageContainer = DataContextStorageFactory.CreateStorageContainer(); ModelBaseContext libraryDataContext = _dataContextStorageContainer.GetDataContext(); if (libraryDataContext == null) { libraryDataContext = new ModelBaseContext(new DbContextOptions <ModelBaseContext>()); _dataContextStorageContainer.Store(libraryDataContext); } return(libraryDataContext); }
//private ModelBaseContext _context; public SysRoleModuleButtonRepository(ModelBaseContext context) : base(context) { //_context = context; }
//private ModelBaseContext _context; public ChildrenRepository(ModelBaseContext context) : base(context) { //_context = context; }
//private ModelBaseContext _context; public SysRoleRepository(ModelBaseContext context) : base(context) { //_context = context; }
//private ModelBaseContext _context; public SysOperateLogRepository(ModelBaseContext context) : base(context) { //_context = context; }
//private ModelBaseContext _context; public MainRepository(ModelBaseContext context) : base(context) { //_context = context; }
//public GaugeRepository(Uow.EFUnitOfWork unitOfWork) :base(unitOfWork) //{ //} public GaugeRepository(ModelBaseContext context) : base(context) { }
//public UserRepository(Uow.EFUnitOfWork unitOfWork) :base(unitOfWork) //{ //} public UserRepository(ModelBaseContext context) : base(context) { }
public BaseRepository(ModelBaseContext context) { _context = context; }
public EFUnitOfWork(ModelBaseContext context) { _context = context; }
//public EnergyRepository(Uow.EFUnitOfWork unitOfWork):base(unitOfWork) //{ //} public EnergyRepository(ModelBaseContext context) : base(context) { }