Beispiel #1
0
        public GetResults <UserDto> GetUsers(PageInput input)
        {
            var result    = GetDefault <GetResults <UserDto> >();
            var q         = _userQuery.GetAll();
            var dsadsa    = q.ToList();
            var filterExp = BuildExpression(input);
            var query     = _userQuery.FindQueryable(q, filterExp, user => user.Id, SortOrder.Descending, input.Current, input.Size);
            var dsadsadsg = query.ToList();

            result.Total = _userQuery.Find(filterExp).Count();

            result.Data = query.Select(user => new UserDto()
            {
                Id         = user.Id,
                CreateTime = user.CreationTime,
                Email      = user.Email,
                State      = user.State,
                Name       = user.Name,
                RealName   = user.RealName,
                Password   = "******",
                Roles      = user.UserRoles.Take(4).Select(z => new BaseEntityDto()
                {
                    Id   = z.Role.Id,
                    Name = z.Role.RoleName
                }).ToList(),

                TotalRole = user.UserRoles.Count()
            }).ToList();

            return(result);
        }
Beispiel #2
0
        public void QueryTest()
        {
            //findSingle
            var findSingleById       = _userQuery.FindSingle(1);
            var findSingleByExp      = _userQuery.FindSingle(p => p.Id == 1);
            var findSingleByExpOrder = _userQuery.FindSingle(p => p.Id == 1, new { name = true });

            //findAll
            var findAll        = _userQuery.FindAll();
            var findAllByOrder = _userQuery.FindAll(new { name = true });

            //findByExp
            var findByExp      = _userQuery.Find(p => p.Id == 1);
            var findByExpOrder = _userQuery.Find(p => p.Id == 1, new { name = true });


            //page
            var page      = _userQuery.Page(1, 10, out var pageCount);
            var pagecount = pageCount;

            var pageByExpOrder      = _userQuery.Page(1, 10, out var pageByExpOrderCount, user => user.Id == 1, new { Name = true });
            var pageByExpOrdercount = pageByExpOrderCount;


            //Count
            var count      = _userQuery.Count();
            var countByExp = _userQuery.Count(p => p.Id > 0);

            //Exists
            var exists = _userQuery.Exists(p => p.Id == 1);
        }
Beispiel #3
0
 private bool IsHasSameName(string name, long userId)
 {
     return(!string.IsNullOrWhiteSpace(name) && _userQuery.Find(u => u.Name == name).Any());
 }