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 7168777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:51:00+00:00 2026-05-28T14:51:00+00:00

I have an MVC telerik grid that I have set up to do custom

  • 0

I have an MVC telerik grid that I have set up to do custom binding to an IQueryable to facilitate the sorting of a calculated column. The default sort behavior when the grid is sorted on this property is this:

data = data.OrderBy(product => product.oneMthCost_IntOnly);

“data” is the IQueryable, product.oneMthCost_IntOnly is not returned from the database, it is a calculated property which is calculated when the “get” accessor is called for this property on the “SearchViewModel”:

public class SearchViewModel
{
    public int ID  { get; set; }
    public string lend_name  { get; set; }
    public decimal? pDes_rate  { get; set; }
    public string pDes_details  { get; set; }
    public int? pDes_totTerm  { get; set; }
    public decimal? pDes_APR  { get; set; }
    public string pDes_revDesc  { get; set; }
    public string pMax_desc  { get; set; }
    public DateTime? dDipNeeded { get; set; }
    public DateTime? dAppNeeded { get; set; }

    public decimal oneMthCost_IntOnly
    {
        get { return ProductOperations.CalculateSingleYearInterestCost(SourcingModel.search.LoanAmt, (decimal)pDes_rate); }
    }
}

To explain how the SearchViewModel (“data”) is returned, it is based on an Entity Data Model that uses the following deferred Linq query as a basis for the grid to project into the SearchViewModel.

    //Return the required products
    var model = from p in Product.Products
                where p.archive == false && ((Prod_ID == 0) || (p.ID == Prod_ID))
                select new SearchViewModel
                    {
                        ID = p.ID,
                        lend_name = p.Lender.lend_name,
                        pDes_rate = p.pDes_rate,
                        pDes_details = p.pDes_details,
                        pDes_totTerm = p.pDes_totTerm,
                        pDes_APR = p.pDes_APR,
                        pDes_revDesc = p.pDes_revDesc,
                        pMax_desc = p.pMax_desc,
                        dDipNeeded = p.dDipNeeded,
                        dAppNeeded = p.dAppNeeded
                    };

Using the grids default behavior, therefore, the below:

data = data.OrderBy(product => product.CalculatedProp);

Throws this error when this column is sorted on:

The specified type member ‘oneMthCost_IntOnly’ is not supported in
LINQ to Entities. Only initializers, entity members, and entity
navigation properties are supported.

Well, this does make sense, the expression tree doesn’t know what this value is going to be until it has got it using the ‘get’ accessor. So, I am quite resigned to the fact I will need to materialize the whole set of objects, do the calculation for each row, and then sort the IQueryable on it (unfortunately the business logic is too complex for the expression tree to turn the calculation into SQL, so a C# method is required). So I do the below:

var calcdata = data.ToList().OrderBy(p => p.oneMthCost_IntOnly);

Which materializes all the data, does all the calculations, and sorts it into an IOrderedEnumerable calcdata… here is the rub:

How do I join “calcdata” to “data” to sort the IQueryable data by IOrderedEnumerable “calcdata”s key? Rebinding the grid to “calcdata” messes up paging, however, if you suggest this is the best way ahead, I can follow this path also.

Apologies this is a bit long winded, there is just quite a lot of information I wanted to include to give you the fullest picture.

Thanks,

Mark

  • 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-28T14:51:01+00:00Added an answer on May 28, 2026 at 2:51 pm

    I was on the right track with the below:

    calcdata = data.ToList().OrderByDescending(p => p.oneMthCost_IntOnly);
    

    This meterializes all of the rows of the data when sorted in this way (not very performant, I know, but it is the only way to be able to do this sort on data the database does not know about). The trouble I was having was the above creates an IOrderedEnumerable, when paging this, as below:

            //Then paging
            if (command.PageSize > 0)
            {
                calcdata = calcdata.Skip((command.Page - 1) * command.PageSize);
            }
    
            calcdata = calcdata.Take(command.PageSize);
    

    This emits an IEnumerable back (where I was assuming it would emit an IOrderedEnumerable), so was trying to cast back to this type which then broke the paging. The above works where calcdata is an IEnumerable, NOT an IOrderedEnumerable. No join is required to the IQueryable (why go back to the database when you have all the information required?), so we rebind to the IEnumerable.

    Thank you for the input Crab Bucket, it led me down some new lines of enquiry that have helped me to eventually sort this problem out!

    Regards,

    Mark

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

Sidebar

Related Questions

I have a telerik MVC 3 grid, that contains checkbox column. if the user
I have a partial view that uses a Telerik MVC Grid, and it has
I have a telerik MVC barchart that uses serverside binding during startup for performance
I have a problem to render column template with Telerik Grid for MVC. I'm
I have a Telerik grid in my asp.net mvc application that looks something like:
I currently have a Telerik MVC Grid that is populated with Patients. What I
A have a razor view with a Telerik MVC grid. The first column has
I'm using Telerik's Grid control from the MVC Extensions. I have it set up
I have a Html.Telerik().Grid() that is bound to a model in my MVC view.
I have a Telerik MVC Grid where there is a column Names , Gender

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.