public IOrderedQueryable <Aluno> OrdernarGrid(string sortOrder, IOrderedQueryable <Aluno> aluno)
        {
            switch (sortOrder)
            {
            case "nomeDesc":
                aluno = aluno.OrderByDescending(x => x.Nome);
                break;

            case "cpfDesc":
                aluno = aluno.OrderByDescending(x => x.Cpf);
                break;

            case "dataDesc":
                aluno = aluno.OrderByDescending(x => x.DataCadastro);
                break;

            case "dataCadastro":
                aluno = aluno.OrderBy(x => x.DataCadastro);
                break;

            case "sexoDesc":
                aluno = aluno.OrderByDescending(x => x.Sexo);
                break;

            case "cidadeDesc":
                aluno = aluno.OrderByDescending(x => x.Endereco.Cidade.Nome);
                break;
            }

            return(aluno);
        }
Esempio n. 2
0
        private async Task <PagingOutput <Schedule> > GetAllFilterAsync(IOrderedQueryable <Schedule> query, int page, int pageSize,
                                                                        SortOprions sort, string search = "")
        {
            if (search != "")
            {
                query = from _ in Context.Set <Schedule>()
                        where _.Personal.UserInfo.SurName.ToLower().Contains(search.ToLower()) ||
                        _.Personal.UserInfo.LastName.ToLower().Contains(search.ToLower()) ||
                        _.Personal.UserInfo.FirstName.ToLower().Contains(search.ToLower()) ||
                        _.Personal.UserInfo.PhoneNumber.ToLower().Contains(search.ToLower()) ||
                        _.Personal.UserInfo.Email.ToLower().Contains(search.ToLower()) ||
                        _.Personal.Polyclinic.Name.ToLower().Contains(search.ToLower()) ||
                        _.Personal.Position.Name.ToLower().Contains(search.ToLower()) ||
                        _.Personal.Polyclinic.Address.ToLower().Contains(search.ToLower())
                        orderby _.Id
                        select _;
            }

            switch (sort)
            {
            case SortOprions.Email:
                query = query.OrderBy(x => x.Personal.UserInfo.Email);
                break;

            case SortOprions.Email_desc:
                query = query.OrderByDescending(x => x.Personal.UserInfo.Email);
                break;

            case SortOprions.Name:
                query = query.OrderBy(x => x.Personal.UserInfo.FirstName);
                break;

            case SortOprions.Name_desc:
                query = query.OrderByDescending(x => x.Personal.UserInfo.FirstName);
                break;

            case SortOprions.Number:
                query = query.OrderBy(x => x.Id);
                break;

            case SortOprions.Number_desc:
                query = query.OrderByDescending(x => x.Id);
                break;

            case SortOprions.Position:
                query = query.OrderBy(x => x.Personal.Position.Name);
                break;

            case SortOprions.Position_desc:
                query = query.OrderByDescending(x => x.Personal.Position.Name);
                break;

            default:
                break;
            }

            return(await CommonRepositoryAsync.GetAllWithPageAsync(query, page, pageSize, _include));
        }
Esempio n. 3
0
        public IOrderedQueryable <Cidade> OrdernarGrid(string sortOrder, IOrderedQueryable <Cidade> cidade)
        {
            switch (sortOrder)
            {
            case "cidadeDesc":
                cidade = cidade.OrderByDescending(x => x.Nome);
                break;

            case "estadoDesc":
                cidade = cidade.OrderByDescending(x => x.Estado.Nome);
                break;
            }

            return(cidade);
        }
        public static IOrderedQueryable <T> SortBy <T, TKey>(
            this IQueryable <T> source,
            IEnumerable <Sort> sort,
            Expression <Func <T, TKey> > defaultSort,
            SortDirection defaultSortDirection = SortDirection.Asc)
        {
            IOrderedQueryable <T> source1          = (IOrderedQueryable <T>)source;
            List <Sort>           scrubbedSortList = SortByExtensions.GetScrubbedSortList <T>(sort);

            if (!scrubbedSortList.Any <Sort>())
            {
                if (defaultSortDirection != SortDirection.Desc)
                {
                    return(source1.OrderBy <T, TKey>(defaultSort));
                }
                return(source1.OrderByDescending <T, TKey>(defaultSort));
            }
            for (int index = 0; index < scrubbedSortList.Count; ++index)
            {
                Sort   sort1   = scrubbedSortList[index];
                string keyword = (index == 0 ? "OrderBy" : "ThenBy") + (sort1.Direction == SortDirection.Desc ? "Descending" : string.Empty);
                source1 = source1.SortOrderedQueryableBy <T>(sort1.Name, keyword);
            }
            return(source1);
        }
        public virtual Task <IEnumerable <TEntity> > GetAllPagedAsync(Expression <Func <TEntity, bool> > predicate, int pageNumber, int itemsPerPage, bool ascending = true, params Expression <Func <TEntity, object> >[] sortingExpression)
        {
            IOrderedQueryable <TEntity> orderedQuery = null;

            if (ascending)
            {
                orderedQuery = GetAll().Where(predicate).OrderBy(sortingExpression[0]);
                for (int i = 1; i < sortingExpression.Length; i++)
                {
                    orderedQuery = orderedQuery.OrderBy(sortingExpression[i]);
                }
            }
            else
            {
                orderedQuery = GetAll().Where(predicate).OrderByDescending(sortingExpression[0]);
                for (int i = 1; i < sortingExpression.Length; i++)
                {
                    orderedQuery = orderedQuery.OrderByDescending(sortingExpression[i]);
                }
            }

            var entities = orderedQuery.Skip((pageNumber + 1) * itemsPerPage)
                           .Take(itemsPerPage)
                           .AsEnumerable();

            return(Task.FromResult(entities));
        }
Esempio n. 6
0
        private IOrderedQueryable<Book> SortDecending(
            IOrderedQueryable<Book> books)
        {
            IOrderedQueryable<Book> orderedBooks = books.OrderByDescending(b => b.Title);

            return orderedBooks;
        }
Esempio n. 7
0
        public static T[] ApplySortingPaging <T>(this IOrderedQueryable <T> query, SortingPagingDto sortingPaging)
        {
            var firstPass = true;

            foreach (var sortOrder in sortingPaging.SortOrders)
            {
                if (firstPass)
                {
                    firstPass = false;
                    query     = sortOrder.ColumnOrder == SortOrderDto.SortOrder.Ascending
                                ? query.OrderBy(sortOrder.ColumnName) :
                                query.OrderByDescending(sortOrder.ColumnName);
                }
                else
                {
                    query = sortOrder.ColumnOrder == SortOrderDto.SortOrder.Ascending
                                ? query.ThenBy(sortOrder.ColumnName) :
                            query.ThenByDescending(sortOrder.ColumnName);
                }
            }

            var result = query.Skip((sortingPaging.PageNumber - 1) *
                                    sortingPaging.NumberRecords).Take(sortingPaging.NumberRecords).ToArray();

            return(result);
        }
        private IOrderedQueryable <Book> SortDecending(
            IOrderedQueryable <Book> books)
        {
            IOrderedQueryable <Book> orderedBooks = books.OrderByDescending(b => b.Title);

            return(orderedBooks);
        }
Esempio n. 9
0
        /// <summary>
        /// 动态排序
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="query"></param>
        /// <param name="sortConditions"></param>
        /// <returns></returns>
        public static IQueryable <T> OrderByCondition <T>(this IQueryable <T> query, IEnumerable <SortCondition> sortConditions)
        {
            var type = typeof(T);

            if (sortConditions != null)
            {
                var i = 0;
                IOrderedQueryable <T> orderQuery = null;
                foreach (var condition in sortConditions)
                {
                    var orderby = GenerateSelector <T>(type, condition.Field);
                    if (ListSortDirection.Ascending == condition.SortDirection)
                    {
                        orderQuery = i == 0 ? query.OrderBy(orderby) : Queryable.ThenBy(orderQuery, orderby);
                    }
                    else if (ListSortDirection.Descending == condition.SortDirection)
                    {
                        orderQuery = i == 0 ? orderQuery.OrderByDescending(orderby) : Queryable.ThenByDescending(orderQuery, orderby);
                    }
                    i++;
                }
                if (orderQuery != null)
                {
                    return(orderQuery);
                }
            }

            return(query);
        }
Esempio n. 10
0
        public static IOrderedQueryable <T> ApplyOrder <T>(this IOrderedQueryable <T> query, string orderColumn,
                                                           SortDirection sortDirection)
        {
            Tracer.Verbose(() => "applying query order");

            if (string.IsNullOrEmpty(orderColumn))
            {
                return(query);
            }

            switch (sortDirection)
            {
            case SortDirection.Ascending:
                Tracer.Verbose(() => "ascending order");
                return(query.OrderBy(orderColumn));

            case SortDirection.Descending:
                Tracer.Verbose(() => "descending order");
                return(query.OrderByDescending(orderColumn));

            default:
                Tracer.Verbose(() => "no ordering applied");
                return(query);
            }
        }
 public static IOrderedQueryable <T> AddOrdering <T, TKey>(this IOrderedQueryable <T> source, Expression <Func <T, TKey> > keySelector, bool descending)
 {
     if (source.Expression.Type != typeof(IOrderedQueryable <T>))
     {
         return(descending ? source.OrderByDescending(keySelector) : source.OrderBy(keySelector));
     }
     return(descending ? ((IOrderedQueryable <T>)source).ThenByDescending(keySelector) : ((IOrderedQueryable <T>)source).ThenBy(keySelector));
 }
Esempio n. 12
0
 public static IOrderedQueryable <TSource> ThenBy <TSource, TKey>(
     this IOrderedQueryable <TSource> source,
     Expression <Func <TSource, TKey> > keySelector,
     bool ascending)
 {
     return(ascending
         ? source.OrderBy(keySelector)
         : source.OrderByDescending(keySelector));
 }
        public IOrderedConfigurableQuery <TEntity, TModel> OrderByDesc <TKey>(Expression <Func <TEntity, TKey> > expression)
        {
            if (IsValid)
            {
                mDbQuery = mDbQuery.OrderByDescending(expression);
            }

            return(this);
        }
Esempio n. 14
0
        public IEnumerable <Movie> SearchByAny(string searchString, int page, int pageSize)
        {
            IOrderedQueryable <Movie> model = db.Movies;

            if (!string.IsNullOrEmpty(searchString))
            {
                model = model.Where(x => x.Name.Contains(searchString)).OrderByDescending(x => x.CreatedDate);
            }
            return(model.OrderByDescending(x => x.CreatedDate).ToPagedList(page, pageSize));
        }
Esempio n. 15
0
        public IEnumerable <Content> ListAll(string searchString, int page, int pageSize)
        {
            IOrderedQueryable <Content> model = db.Contents;

            if (!string.IsNullOrEmpty(searchString))
            {
                model = (IOrderedQueryable <Content>)model.Where(x => x.MetaTitle.Contains(searchString) || x.Name.Contains(searchString));
            }
            return(model.OrderByDescending(x => x.ID).ToPagedList(page, pageSize));
        }
Esempio n. 16
0
            /// <summary>
            /// Creates Ordered query based on stored expressions and delegates.
            /// For row columns that have identical names with db columns, the order is made automatically
            /// </summary>
            /// <param name="query">Query that will be ordered</param>
            /// <param name="defaultOrderFunc">Default order row column. The query must be ordered before take/skip</param>
            /// <returns>Ordered query</returns>
            public IOrderedQueryable <TEntity> Order(IQueryable <TEntity> query, Func <IQueryable <TEntity>, IOrderedQueryable <TEntity> > defaultOrderFunc)
            {
                //throw exception if defaultOrder is not asc or desc
                if (defaultOrderFunc == null)
                {
                    throw new Exception("you must implement a func for default order");
                }

                IOrderedQueryable <TEntity> orderedQuery = defaultOrderFunc(query);

                if (this.columnsOrder != null && this.columnsOrder.Any())
                {
                    this.columnsOrder.Reverse();

                    //order dict desc and order query based on Order priority
                    foreach (var item in this.columnsOrder)
                    {
                        var name = item.Name;

                        if (this.expressionSettings.ContainsKey(name))
                        {
                            var criteria = this.expressionSettings[name];

                            if (item.Type == BsOrderType.Ascending)
                            {
                                orderedQuery = criteria.OrderBy(orderedQuery);
                            }
                            else if (item.Type == BsOrderType.Descending)
                            {
                                orderedQuery = criteria.OrderByDescending(orderedQuery);
                            }

                            continue;
                        }

                        if (this.delegateSettings.ContainsKey(name))
                        {
                            orderedQuery = this.delegateSettings[name](orderedQuery, item.Type);

                            continue;
                        }

                        if (item.Type == BsOrderType.Ascending)
                        {
                            orderedQuery = orderedQuery.OrderBy(name);
                        }
                        else if (item.Type == BsOrderType.Descending)
                        {
                            orderedQuery = orderedQuery.OrderByDescending(name);
                        }
                    }
                }

                return(orderedQuery);
            }
Esempio n. 17
0
        public IEnumerable <User> ListAllPaging(string searchString, int page, int pageSize)
        {
            IOrderedQueryable <User> model = db.Users;

            if (!string.IsNullOrEmpty(searchString))
            {
                model = model.Where(x => x.UserName.Contains(searchString) || x.Name.Contains(searchString)).OrderByDescending(x => x.CreatedDate);
            }

            return(model.OrderByDescending(x => x.CreatedDate).ToPagedList(page, pageSize));
        }
Esempio n. 18
0
        public static IOrderedQueryable <T> AddOrderBy <T, TKey>(this IOrderedQueryable <T> q,
                                                                 Expression <Func <T, TKey> > orderExpression, bool isDescending = false)
        {
            var hasBeenOrdered = q.IsOrdered();

            if (hasBeenOrdered)
            {
                return(!isDescending?q.ThenBy(orderExpression) : q.ThenByDescending(orderExpression));
            }
            return(!isDescending?q.OrderBy(orderExpression) : q.OrderByDescending(orderExpression));
        }
Esempio n. 19
0
 protected override IOrderedQueryable <Person> AddSortDescending(IOrderedQueryable <Person> query, string propertyName, bool isFirstSort)
 {
     if (propertyName == "FirstName")
     {
         if (isFirstSort == true)
         {
             return(query.OrderByDescending(x => x.FirstName));
         }
         else
         {
             return(query.ThenByDescending(x => x.FirstName));
         }
     }
     else if (propertyName == "LastName")
     {
         if (isFirstSort == true)
         {
             return(query.OrderByDescending(x => x.LastName));
         }
         else
         {
             return(query.ThenByDescending(x => x.LastName));
         }
     }
     else if (propertyName == "Id")
     {
         if (isFirstSort == true)
         {
             return(query.OrderByDescending(x => x.Id));
         }
         else
         {
             return(query.ThenByDescending(x => x.Id));
         }
     }
     else
     {
         return(null);
     }
 }
Esempio n. 20
0
        public IEnumerable <Thuoc> ListAllPaging(string searchString, int page, int pageSize)
        {
            IOrderedQueryable <Thuoc> model = db.Thuoc;

            if (!string.IsNullOrEmpty(searchString))
            {
                //contains kiểm tra chuỗi gần đúng
                model = model.Where(x => x.MaThuoc.Contains(searchString) || x.TenThuoc.Contains(searchString)).OrderByDescending(x => x.MaThuoc);
            }

            //tìm theo nhóm , ngày tháng => thêm if ()

            return(model.OrderByDescending(x => x.MaThuoc).ToPagedList(page, pageSize));
        }
Esempio n. 21
0
        public IEnumerable <Account> ListAllPaging(string searchString, int page, int pageSize)
        {
            IOrderedQueryable <Account> model = db.Account;

            if (!string.IsNullOrEmpty(searchString))
            {
                //contains kiểm tra chuỗi gần đúng
                model = model.Where(x => x.UserName.Contains(searchString) || x.PhanQuyen.Contains(searchString)).OrderByDescending(x => x.MaTK);
            }

            //tìm theo nhóm , ngày tháng => thêm if ()

            return(model.OrderByDescending(x => x.MaTK).ToPagedList(page, pageSize));
        }
 /// <summary>
 /// The ThenBy.
 /// </summary>
 /// <typeparam name="TSource">.</typeparam>
 /// <typeparam name="TKey">.</typeparam>
 /// <param name="source">The source<see cref="IOrderedQueryable{TSource}"/>.</param>
 /// <param name="keySelector">The keySelector<see cref="System.Linq.Expressions.Expression{Func{TSource, TKey}}"/>.</param>
 /// <param name="sortOrder">The sortOrder<see cref="SortDirection"/>.</param>
 /// <param name="comparer">The comparer<see cref="IComparer{TKey}"/>.</param>
 /// <returns>The <see cref="IOrderedQueryable{TSource}"/>.</returns>
 public static IOrderedQueryable <TSource> ThenBy <TSource, TKey>(this IOrderedQueryable <TSource> source,
                                                                  System.Linq.Expressions.Expression <Func <TSource, TKey> > keySelector,
                                                                  SortDirection sortOrder, IComparer <TKey> comparer
                                                                  )
 {
     if (sortOrder == SortDirection.ASC)
     {
         return(source.OrderBy(keySelector));
     }
     else
     {
         return(source.OrderByDescending(keySelector));
     }
 }
Esempio n. 23
0
        /// <summary>
        /// 排序
        /// </summary>
        /// <returns></returns>
        private IOrderedQueryable <DetailInfo> order(IOrderedQueryable <DetailInfo> list, string orderfield, int sortorder)
        {
            switch (orderfield.ToLower())
            {
            case "hitsnum":
                if (sortorder == 0)
                {
                    return(list.OrderBy(g => g.HitsNum));
                }
                else
                {
                    return(list.OrderByDescending(g => g.HitsNum));
                }

            case "agreenum":
                if (sortorder == 0)
                {
                    return(list.OrderBy(g => g.AgreeNum));
                }
                else
                {
                    return(list.OrderByDescending(g => g.AgreeNum));
                }

            case "follownum":
                if (sortorder == 0)
                {
                    return(list.OrderBy(g => g.FollowNum));
                }
                else
                {
                    return(list.OrderByDescending(g => g.FollowNum));
                }
            }
            return(list);
        }
Esempio n. 24
0
        public static IOrderedQueryable <TSource> SortBy <TSource, TKey>(
            this IOrderedQueryable <TSource> source,
            Expression <Func <TSource, TKey> > keySelector,
            SortDirection direction,
            int sortIndex)
        {
            if (sortIndex == 0)
            {
                return(direction == SortDirection.Asc
                    ? source.OrderBy(keySelector)
                    : source.OrderByDescending(keySelector));
            }

            return(direction == SortDirection.Asc
                ? source.ThenBy(keySelector)
                : source.ThenByDescending(keySelector));
        }
Esempio n. 25
0
        public static IOrderedQueryable <T> OrderExpressionToOrderedQueryable <T>(this IQueryable <T> query, IOrder <T> order) where T : BaseEntity
        {
            var orderSelector = order.Getstock();

            if (orderSelector == null || orderSelector.Count() == 0)
            {
                return(query.OrderBy(t => true));
            }
            else if (orderSelector.Values.Count == 1)
            {
                var orderExpression = orderSelector.First();
                if (orderExpression.Value == QueryOrderBy.Asc)
                {
                    return(query.OrderBy(orderExpression.Key));
                }
                else
                {
                    return(query.OrderByDescending(orderExpression.Key));
                }
            }
            else
            {
                IOrderedQueryable <T> orderQuery = null;
                var firstOrderExpression         = orderSelector.First();
                if (firstOrderExpression.Value == QueryOrderBy.Asc)
                {
                    orderQuery = query.OrderBy(firstOrderExpression.Key);
                }
                else
                {
                    orderQuery = query.OrderByDescending(firstOrderExpression.Key);
                }
                foreach (var orderExpression in orderSelector)
                {
                    if (orderExpression.Value == QueryOrderBy.Asc)
                    {
                        orderQuery = orderQuery.OrderBy(orderExpression.Key);
                    }
                    else
                    {
                        orderQuery = orderQuery.OrderByDescending(orderExpression.Key);
                    }
                }
                return(orderQuery);
            }
        }
Esempio n. 26
0
        private static IQueryable <TEntity> AddOrderBys(IOrderedQueryable <TEntity> dbSet, QueryBuilder <TEntity> queryBuilder)
        {
            bool first = true;

            foreach (QuerySortExpression <TEntity> sortExpression in queryBuilder.SortExpressions)
            {
                if (sortExpression.Direction == QuerySortDirections.Ascending)
                {
                    dbSet = first ? dbSet.OrderBy(sortExpression.Expression) : dbSet.ThenBy(sortExpression.Expression);
                }
                else
                {
                    dbSet = first ? dbSet.OrderByDescending(sortExpression.Expression) : dbSet.ThenByDescending(sortExpression.Expression);
                }
                first = false;
            }
            return(dbSet);
        }
Esempio n. 27
0
        private static IOrderedQueryable <T> OrderQuery <T>(Tuple <string, SortOrder> sortCriteria,
                                                            IOrderedQueryable <T> query, bool firstRun)
        {
            var typeParameter = Expression.Parameter(typeof(T), "entity");
            var access        = Expression.Property(typeParameter, sortCriteria.Item1);

            var lambda = Expression.Lambda <Func <T, object> >(
                Expression.Convert(access, typeof(object)), typeParameter);

            if (sortCriteria.Item2 == SortOrder.Ascending)
            {
                return(firstRun ? query.OrderBy(lambda) : query.ThenBy(lambda));
            }
            else
            {
                return(firstRun ? query.OrderByDescending(lambda) : query.ThenByDescending(lambda));
            }
        }
        public static IPagedList <T> ApplySortingPaging <T>(this IOrderedQueryable <T> query, PageSortCriteria pageSortCriteria, string defaultSort)
        {
            bool   isDescending = false;
            string sortBy       = defaultSort;

            if (!string.IsNullOrWhiteSpace(pageSortCriteria.Sort))
            {
                sortBy = pageSortCriteria.Sort;
                if (sortBy.StartsWith("-"))
                {
                    sortBy       = sortBy.Substring(1);
                    isDescending = true;
                }
            }
            query = isDescending ? query.OrderByDescending(sortBy) : query.OrderBy(sortBy);

            return(query.ToPagedList <T>(pageSortCriteria.Page, pageSortCriteria.ItemsPerPage));
        }
        public static IOrderedQueryable <TEntity> ApplyOrdering <TEntity>(this IQueryable <TEntity> query, Dictionary <string, Expression <Func <TEntity, object> > > columnsMap, string sortBy, bool isAsc = true)
        {
            IOrderedQueryable <TEntity> orderedQuery = (IOrderedQueryable <TEntity>)query;

            if (string.IsNullOrEmpty(sortBy) || columnsMap == null || !columnsMap.ContainsKey(sortBy))
            {
                return(orderedQuery);
            }

            if (isAsc)
            {
                return(orderedQuery.OrderBy(columnsMap[sortBy]));
            }
            else
            {
                return(orderedQuery.OrderByDescending(columnsMap[sortBy]));
            }
        }
Esempio n. 30
0
        public Level GetNextNonCompleteLevel(int playerId)
        {
            Level        nextLevel;
            LevelAttempt highestCompletedLevelAttempt = GetHighestCompletedLevelAttemptForPlayer(playerId);

            IOrderedQueryable <Level> orderedLevels = GetOrderedLevels();

            if (highestCompletedLevelAttempt == null)
            {
                //the player has not completed any levels, so just get the first
                nextLevel = orderedLevels.First(l => l.Active);
            }
            else
            {
                //check to see if there is another level in the current world
                nextLevel =
                    orderedLevels
                    .SingleOrDefault(
                        l =>
                        l.World == highestCompletedLevelAttempt.Level.World &&
                        l.SequenceInWorld == highestCompletedLevelAttempt.Level.SequenceInWorld + 1);

                if (nextLevel == null)
                {
                    //check to see if there is a next world
                    nextLevel =
                        orderedLevels
                        .SingleOrDefault(
                            l =>
                            l.World == highestCompletedLevelAttempt.Level.World + 1 &&
                            l.SequenceInWorld == 1);
                }

                if (nextLevel == null)
                {
                    //the player has completed all levels, so just return the last level
                    nextLevel =
                        orderedLevels.OrderByDescending(o => o.World).ThenByDescending(o => o.SequenceInWorld)
                        .First();
                }
            }

            return(nextLevel);
        }
        public static IOrderedQueryable <TEntity> ApplyOrdering <TEntity>(this IQueryable <TEntity> query, Dictionary <string, Expression <Func <TEntity, object> > > columnsMap, string multipleSortBy)
        {
            IOrderedQueryable <TEntity> orderedQuery = (IOrderedQueryable <TEntity>)query;
            var orderByList = multipleSortBy.Split(',');

            if (!orderByList.Any())
            {
                return(orderedQuery);
            }

            var orderBy = orderByList[0];
            var prop    = orderBy.Split(' ')[0];

            if (orderBy.Split(' ')[1] == "asc" && columnsMap.ContainsKey(prop))
            {
                orderedQuery = orderedQuery.OrderBy(columnsMap[prop]);
            }
            else if (columnsMap.ContainsKey(prop))
            {
                orderedQuery = orderedQuery.OrderByDescending(columnsMap[prop]);
            }
            else
            {
                orderedQuery = orderedQuery.OrderBy(x => x);
            }

            for (int i = 1; i < orderByList.Length; i++)
            {
                orderBy = orderByList[i];
                prop    = orderBy.Split(' ')[0];

                if (orderBy.Split(' ')[1] == "asc" && columnsMap.ContainsKey(prop))
                {
                    orderedQuery = orderedQuery.ThenBy(columnsMap[prop]);
                }
                else if (columnsMap.ContainsKey(prop))
                {
                    orderedQuery = orderedQuery.ThenByDescending(columnsMap[prop]);
                }
            }

            return(orderedQuery);
        }