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

  • Home
  • SEARCH
  • 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 4005074
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:21:00+00:00 2026-05-20T08:21:00+00:00

I am following Phil Haacks tutorial on using JQGrid with ASP.Net MVC. My application

  • 0

I am following Phil Haacks tutorial on using JQGrid with ASP.Net MVC. My application is ASP.Net MVC 3 using Entity Framework 4.

I have the following code to perform the sorting and paging for my data which is returned to the JQGrid

var query = equipService.GetAllEquipment().AsQueryable()
                .OrderBy("it." + sidx + " " + sord)
                .Skip(pageIndex * pageSize)
                .Take(pageSize);

However, this code creates an error at the .OrderBy(“it.” + sidx + ” ” + sord) line. The error is

System.Linq.Queryable.OrderBy<TSource,TKey>(System.Linq.IQueryable<TSource>, System.Linq.Expressions.Expression<System.Func<TSource,TKey>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

The query is calling a method, GetAllEquipment(), in my service layer which looks like this

public List<Equipment> GetAllEquipment()
    {
        List<Equipment> equipList = new List<Equipment>();
        equipList = equipRepository.GetAllEquipment();

        return equipList;
    }

This method, then calls the same name of method in my repository, like so

public List<Equipment> GetAllEquipment()
    {
        var query = (from e in Data.DBEntities.Equipments
                     select e).ToList();

        return query;
    }

I can kind of solve the problem by creating an instance of my objectcontext in my controller method and use this code

using (AssetEntities context = new AssetEntities())
        {
            int pageIndex = Convert.ToInt32(page) - 1;
            int pageSize = rows;
            int totalRecords = context.Equipments.Count();
            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);


            var query = context.Equipments
              .OrderBy("it." + sidx + " " + sord)
              .Skip(pageIndex * pageSize)
              .Take(pageSize);

        }

However, I don’t really want to do this, rather I would like to keep to the repository pattern I use throughout my application for all database interaction.

Any ideas on how I can fix this?

Thanks as ever everyone.

  • 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-05-20T08:21:01+00:00Added an answer on May 20, 2026 at 8:21 am

    I recommed you to use PropertyInfo, GetProperty or FieldInfo, GetField depend on your data model. In the case you can implement OrderBy operation without any extensions. See the answer for details.

    UPDATED: I reread your question carefully one more time. It seems to me, that your problem is inside of GetAllEquipment method. It returns List<Equipment> and not IQueryable<Equipment>. So the GetAllEquipment method get “SELECT * FROM it.Equipment” and return the data as a List which are no more Entity. With equipService.GetAllEquipment().AsQueryable() you will have IQueryable<Equipment> object, but you will not more use LINQ to Entity and so you should not use “it.” prefix before the names.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am following Phil Haack's example on using jQuery Grid with ASP.NET MVC .
I have recently started using ASP.Net MVC 3 RC 2 and have attempted to
I'm developing an asp.net (classic) application trying to implement the MVP pattern using this
I'm running asp.net MVC site on IIS6 - I've edited my routing to look
What is the final/best recommendation for how to serve favicon.ico in ASP.NET MVC? I
Following StockWatcher tutorial, http://code.google.com/webtoolkit/doc/latest/tutorial/debug.html When I run the app in debug mode, my Safari
I'm getting the following error in my Rails application and I have no idea
Following my question regarding a .NET YAML Library ... as there doesn't seem to
Following is some obviously-defective code for which I think the compiler should emit a
I am playing around with VirtualPC and following Phil Haack's instructions for how to

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.