Exemple #1
0
 public static IQueryable <T> ApplySorting <T>(this IQueryable <T> query, IQuerySort querySort, Dictionary <string, Expression <Func <T, object> > > columnsMap)
 {
     if (String.IsNullOrWhiteSpace(querySort.SortBy) || !columnsMap.ContainsKey(querySort.SortBy))
     {
         return(query);
     }
     return(querySort.IsSortAsc ? query.OrderBy(columnsMap[querySort.SortBy.ToLower()]) : query.OrderByDescending(columnsMap[querySort.SortBy.ToLower()]));
 }
Exemple #2
0
        public async Task <IEnumerable <IDomainUser> > SearchByProperties(string query, IQuerySort sort, IQueryPaging paging)
        {
            var usersId = await(
                from user in _store.Set <TUser>().AsQueryable()
                join claim in _store.Set <IdentityUserClaim <TKey> >().AsQueryable() on user.Id equals claim.UserId into userClaims
                from c in userClaims.DefaultIfEmpty()
                where
                (user.UserName.Contains(query) ||
                 user.Email.Contains(query) ||
                 c.ClaimValue.Contains(query)) ||
                query == null
                group user by user.Id)
                          .Sort(sort)
                          .Paginate(paging)
                          .Select(s => s.Key)
                          .ToListAsync();

            return(_userManager.Users.Where(w => usersId.Contains(w.Id)));
        }