Example #1
0
        /// <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);
        }
Example #2
0
 /// <summary>
 /// 动态获取所有
 /// </summary>
 /// <returns></returns>
 protected override IQueryable <TEntity> DynamicGetAll(IDynamicRouter router)
 {
     return(EfUnitOfWork.CreateSet(DbFactory.GetDynamicDbConfig(typeof(TEntity), router), DbMode.Read));
 }
Example #3
0
        //private DbSet<TEntity> _writeEntities;

        /// <summary>
        /// 创建上下文的实体对象
        /// </summary>
        /// <returns></returns>
        protected virtual DbSet <TEntity> GetSet()
        {
            return(_entities ?? (_entities = _unitOfWork.CreateSet <TEntity, TPrimaryKey>()));
        }
Example #4
0
 protected virtual DbSet <TEntity> GetSet()
 {
     return(_entities ?? (_entities =
                              EfUnitOfWork.CreateSet(DbFactory.GetStaticDbConfig(typeof(TEntity)), DbMode.Write | DbMode.Read)));
 }
Example #5
0
 /// <summary>
 ///获取所有的实体
 /// </summary>
 /// <returns>List of selected elements</returns>
 public override IQueryable <TEntity> GetAll()
 {
     //todo 数据权限
     return(_unitOfWork.CreateSet(_dbFactory.GetStaticDbConfig(typeof(TEntity)), DbMode.Read));
 }
Example #6
0
 protected DbSet <TEntity> GetSet()
 {
     return(_unitOfWork.CreateSet <TEntity, TPrimaryKey>());
 }
 private DbSet <TEntity> GetSet()
 {
     return(_unitOfWork.CreateSet <TEntity>());
 }