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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:22:54+00:00 2026-05-23T23:22:54+00:00

I have an ObjectQuery like that: ObjectQuery<Car> query = GetCarQuery(); than i want to

  • 0

I have an ObjectQuery like that:

ObjectQuery<Car> query = GetCarQuery();

than i want to order by property Date on related entity Race, somehting like

query = (ObjectQuery<Car>)query.OrderBy(x=> x.Races.Date); 
query.Skip((page - 1) * rows).Take(rows).ToList();

was trying to go like that:

query = (ObjectQuery<Car>)query.OrderBy(i => i.Races.OrderBy(x=> x.Date));
query.Skip((page - 1) * rows).Take(rows).ToList(); //error here

and got an error when query executed

DbSortClause expressions must have a type that is order comparable.
Parameter name: key

Any ideas?

UPDATE:

After reading that http://blogs.msdn.com/b/alexj/archive/2009/02/25/tip-1-sorting-relationships-in-entity-framework.aspx i go like this:

var result =  (from a in query
                        select new 
                 {
                     Car= a,
                     Race= a.Races.OrderBy(x => x.Date)
                 }).Skip((page - 1) * rows).Take(rows).ToList();

Didn’t get any errors but sorting seams to be not working.

One more try but with Entity SQL:

 query = query.OrderBy("it.Races.Date");
 query = query.Skip((page - 1) * rows).Take(rows).ToList();//error here

and getting error:

'Date' is not a member of 'Transient.collection[Race(Nullable=True,DefaultValue=)]'. To extract a property of a collection element, use a subquery to iterate over the collection. Near simple identifier, line 6, column 28.

So i think I’ve tried everything i could…

  • 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-23T23:22:56+00:00Added an answer on May 23, 2026 at 11:22 pm

    And how do you expect it should work? You have cars and each of them can have many races so you cannot sort cars by race’s data unless you do either:

    • Sort cars with some aggregation of races – for example .OrderBy(x=> x.Races.Max(Date))
    • Flatten the result to have new record for each race (duplication of car)

    For second solution you can try something like:

    var result =  (from car in query
                   from race in car.Races
                   select new 
                     {
                        Car = car,
                        Race = race
                     })
                  .OrderBy(x => x.Race.Data)
                  .Skip((page - 1) * rows)
                  .Take(rows).ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following LINQ query that I need to translate to Entity SQL
I have a simple entity framework query in an MVC3 app, like so var
I have a query that I'd like to pre-compile, however the query is being
I have a strange behavior trying to execute a query declaring ObjectQuery MergeOption to
I have a problem that I know is something local, related to transaction scope,
I have an ADO.NET Entity Data Model and want to plumb up a DataGridView
I have a Linq (Entity Framework) Query as function getData(string col_to_sort , bool IsAscending
I have a WinForms application which is using Entity Framework to query a database.
I have a query that will go away an and find data Dim HSNs
I have been trying to use dynamic LINQ to Entity in my application for

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.