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 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 a query that I'd like to pre-compile, however the query is being
I have a problem that I know is something local, related to transaction scope,
Have String str May 23 2011 12:20:00, want to convert it to date such
We have a form that allows a user to filter a list with by
I have some code for strongly typing Includes()'s in linq, like so... public static
Class documentation here . The InstalledOn property is supposed to have a timestamp of
I have this query and its result implements IEnumerable . RoutesEntities routesModel = new
Have noticed issue while testing iphone app that if one quickly opens/dismisses a modal
I have a project that adds elements to an AutoCad drawing. I noticed that
I have a script that appends some rows to a table. One of the

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.