/// <summary> /// 添加实体 /// </summary> /// <param name="item"></param> public void Add(TEntity item) { if (item.Id == 0) { item.Id = IdentityGenerator.NextId(DbFactory.GetDynamicDbConfig(typeof(TEntity), item).Number); } EfUnitOfWork.CreateSet(DbFactory.GetDynamicDbConfig(typeof(TEntity), item), DbMode.Write).Add(item); }
/// <summary> /// 动态获取所有 /// </summary> /// <returns></returns> protected override IQueryable <TEntity> DynamicGetAll(IDynamicRouter router) { return(EfUnitOfWork.CreateSet(DbFactory.GetDynamicDbConfig(typeof(TEntity), router), DbMode.Read)); }
//private DbSet<TEntity> _writeEntities; /// <summary> /// 创建上下文的实体对象 /// </summary> /// <returns></returns> protected virtual DbSet <TEntity> GetSet() { return(_entities ?? (_entities = _unitOfWork.CreateSet <TEntity, TPrimaryKey>())); }
protected virtual DbSet <TEntity> GetSet() { return(_entities ?? (_entities = EfUnitOfWork.CreateSet(DbFactory.GetStaticDbConfig(typeof(TEntity)), DbMode.Write | DbMode.Read))); }
/// <summary> ///获取所有的实体 /// </summary> /// <returns>List of selected elements</returns> public override IQueryable <TEntity> GetAll() { //todo 数据权限 return(_unitOfWork.CreateSet(_dbFactory.GetStaticDbConfig(typeof(TEntity)), DbMode.Read)); }
protected DbSet <TEntity> GetSet() { return(_unitOfWork.CreateSet <TEntity, TPrimaryKey>()); }
private DbSet <TEntity> GetSet() { return(_unitOfWork.CreateSet <TEntity>()); }