Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8261423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:24:10+00:00 2026-06-08T03:24:10+00:00

I was trying to implement the jQgrid using MvcjQgrid and i got this exception.

  • 0

I was trying to implement the jQgrid using MvcjQgrid and i got this exception.

System.NotSupportedException was unhandled by user code
  Message=The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.

Though OrdeyBy is used before Skip method why it is generating the exception? How can it be solved?

I encountered the exception in the controller:

public ActionResult GridDataBasic(GridSettings gridSettings)
        {          
            var jobdescription = sm.GetJobDescription(gridSettings);
            var totalJobDescription = sm.CountJobDescription(gridSettings);

            var jsonData = new
            {
                total = totalJobDescription / gridSettings.PageSize + 1,
                page = gridSettings.PageIndex,
                records = totalJobDescription,
                rows = (
                    from j in jobdescription
                    select new
                    {
                        id = j.JobDescriptionID,
                        cell = new[] 
                    { 
                        j.JobDescriptionID.ToString(), 
                        j.JobTitle,
                        j.JobType.JobTypeName,
                        j.JobPriority.JobPriorityName,
                        j.JobType.Rate.ToString(),
                        j.CreationDate.ToShortDateString(),
                         j.JobDeadline.ToShortDateString(),

                    }
                    }).ToArray()
            };
            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }

GetJobDescription Method and CountJobDescription Method

public int CountJobDescription(GridSettings gridSettings)
        {
            var jobdescription = _dataContext.JobDescriptions.AsQueryable();

            if (gridSettings.IsSearch)
            {
                jobdescription = gridSettings.Where.rules.Aggregate(jobdescription, FilterJobDescription);
            }
            return jobdescription.Count();
        }

        public IQueryable<JobDescription> GetJobDescription(GridSettings gridSettings)
        {
            var jobdescription = orderJobDescription(_dataContext.JobDescriptions.AsQueryable(), gridSettings.SortColumn, gridSettings.SortOrder);

            if (gridSettings.IsSearch)
            {
                jobdescription = gridSettings.Where.rules.Aggregate(jobdescription, FilterJobDescription);
            }

            return jobdescription.Skip((gridSettings.PageIndex - 1) * gridSettings.PageSize).Take(gridSettings.PageSize);
        }

And Finally FilterJobDescription and OrderJobDescription

private static IQueryable<JobDescription> FilterJobDescription(IQueryable<JobDescription> jobdescriptions, Rule rule)
        {
            if (rule.field == "JobDescriptionID")
            {
                int result;
                if (!int.TryParse(rule.data, out result))
                    return jobdescriptions;
                return jobdescriptions.Where(j => j.JobDescriptionID == Convert.ToInt32(rule.data));

            }

// Similar Statements

            return jobdescriptions;
        }



private IQueryable<JobDescription> orderJobDescription(IQueryable<JobDescription> jobdescriptions, string sortColumn, string sortOrder)
        {
            if (sortColumn == "JobDescriptionID")
                return (sortOrder == "desc") ? jobdescriptions.OrderByDescending(j => j.JobDescriptionID) : jobdescriptions.OrderBy(j => j.JobDescriptionID);

            return jobdescriptions;
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:24:12+00:00Added an answer on June 8, 2026 at 3:24 am

    The exception means that you always need a sorted input if you apply Skip, also in the case that the user doesn’t click on a column to sort by. I could imagine that no sort column is specified when you open the grid view for the first time before the user can even click on a column header. To catch this case I would suggest to define some default sorting that you want when no other sorting criterion is given, for example:

    switch (sortColumn)
    {
        case "JobDescriptionID":
            return (sortOrder == "desc")
                ? jobdescriptions.OrderByDescending(j => j.JobDescriptionID)
                : jobdescriptions.OrderBy(j => j.JobDescriptionID);
    
        case "JobDescriptionTitle":
            return (sortOrder == "desc")
                ? jobdescriptions.OrderByDescending(j => j.JobDescriptionTitle)
                : jobdescriptions.OrderBy(j => j.JobDescriptionTitle);
    
        // etc.
    
        default:
            return jobdescriptions.OrderBy(j => j.JobDescriptionID);
    }
    

    Edit

    About your follow-up problems according to your comment: You cannot use ToString() in a LINQ to Entities query. And the next problem would be that you cannot create a string array in a query. I would suggest to load the data from the DB with their native types and then convert afterwards to strings (and to the string array) in memory:

    rows = (from j in jobdescription
            select new
            {
                JobDescriptionID = j.JobDescriptionID,
                JobTitle = j.JobTitle,
                JobTypeName = j.JobType.JobTypeName,
                JobPriorityName = j.JobPriority.JobPriorityName,
                Rate = j.JobType.Rate,
                CreationDate = j.CreationDate,
                JobDeadline = j.JobDeadline
            })
            .AsEnumerable() // DB query runs here, the rest is in memory
            .Select(a => new
            {
                id = a.JobDescriptionID,
                cell = new[] 
                { 
                    a.JobDescriptionID.ToString(), 
                    a.JobTitle,
                    a.JobTypeName,
                    a.JobPriorityName,
                    a.Rate.ToString(),
                    a.CreationDate.ToShortDateString(),
                    a.JobDeadline.ToShortDateString()
                }
            })
            .ToArray()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement jqgrid v3.7 in my webapplication created using cakephp v1.3.
Im trying to implement a UnitofWork pattern using this Scott Allen tutorial My current
I'm trying to implement a simple function using jqGrid, but it doesn't seem to
I am trying implement the Data transformation using Reflection 1 example in my code.
Trying to implement LoaderManager + CursorLoader. In onFinish method adapter should swap its cursor
Trying to implement a search similar to here .This searches properties based on city,locality,property
Trying to implement a rating system of users and postings. What is the best
Found a really nice code for Accordion nav and am trying implement on our
Trying to implement the decorator pattern in C# from the code in the Head
I'm trying to implement jqgrid search on MVC, following the interesting answer by @Oleg,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.