Пример #1
0
        public void TestConvert()
        {
            var result = _list.Convert(t => new EmployeeDto());

            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(1, result.Page);
            Assert.AreEqual(2, result.PageSize);
            Assert.AreEqual(3, result.TotalCount);
            Assert.AreEqual(2, result.PageCount);
        }
Пример #2
0
        public void TestConvert()
        {
            var result = _list.Convert(t => new AggregateRootSample());

            Assert.Equal(2, result.Data.Count);
            Assert.Equal(1, result.Page);
            Assert.Equal(2, result.PageSize);
            Assert.Equal(3, result.TotalCount);
            Assert.Equal(2, result.PageCount);
            Assert.Equal("Name", result.Order);
        }
Пример #3
0
        public void TestConvert()
        {
            var result = _list.Convert(t => new CustomerInfo());

            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(1, result.Page);
            Assert.AreEqual(2, result.PageSize);
            Assert.AreEqual(3, result.TotalCount);
            Assert.AreEqual(2, result.PageCount);
            Assert.AreEqual("Name", result.Order);
        }
Пример #4
0
        //[DisableFiltersAttribute(FiltersEnum.SoftDelete)]   //示范:关闭数据过滤器(参数为过滤器名称列表)
        public PagerList <UserDto> Query(UserQuery query)
        {
            //todo:easyui组件的ajax请求异常,暂时无法拦截
            //throw new Exception("用户查询异常,easyui ajax操作全局异常测试");
            if (string.IsNullOrWhiteSpace(query.Order))   //分页必须先进行排序
            {
                query.Order = "Id desc";
            }
            query.TotalCount = _userRepository.GetAllFilterDataPermissions().Count();
            IQueryable <User> users = GetQueryConditions(_userRepository.GetAllFilterDataPermissions(), query)   //where查询条件必须放在排序和分页前,不然生成SQL有BUG
                                      .OrderByIfOrderNullOrEmpty(query.Order)
                                      .Skip(query.GetSkipCount())
                                      .Take(query.PageSize);
            var result = new PagerList <User>(query);

            result.AddRange(users.ToList());
            return(result.Convert(p => p.ToDto()));
        }
Пример #5
0
 public PagerList<UserDto> Query(UserQuery query)
 {
     //todo:easyui组件的ajax请求异常,暂时无法拦截
     //throw new Exception("用户查询异常,easyui ajax操作全局异常测试");
     if (string.IsNullOrWhiteSpace(query.Order))   //分页必须先进行排序
         query.Order = "Id desc";
     query.TotalCount = _userRepository.GetAllFilterDataPermissions().Count();
     IQueryable<User> users = GetQueryConditions(_userRepository.GetAllFilterDataPermissions(), query)   //where查询条件必须放在排序和分页前,不然生成SQL有BUG
         .OrderByIfOrderNullOrEmpty(query.Order)
             .Skip(query.GetSkipCount())
             .Take(query.PageSize);
     var result = new PagerList<User>(query);
     result.AddRange(users.ToList());
     return result.Convert(p => p.ToDto());
 }