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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:36:40+00:00 2026-06-17T17:36:40+00:00

I get this error: DbSortClause expressions must have a type that is order comparable.

  • 0

I get this error:

DbSortClause expressions must have a type that is order comparable. Parameter name: key | at System.Data.Common.CommandTrees.ExpressionBuilder.Internal.ArgumentValidation.ValidateSortClause(DbExpression key) at System.Data.Common.CommandTrees.ExpressionBuilder.DbExpressionBuilder.ToSortClause(DbExpression key) at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.OrderByTranslatorBase.TranslateOneLambda(ExpressionConverter parent, DbExpressionBinding sourceBinding, DbExpression lambda) at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.OneLambdaTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, DbExpression& source, DbExpressionBinding& sourceBinding, DbExpression& lambda) at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.OneLambdaTranslator.Translate(ExpressionConverter parent, MethodCallExpression call) at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.SequenceMethodTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, SequenceMethod sequenceMethod) at System.Data.Objects.ELinq.ExpressionConverter.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq) at System.Data.Objects.ELinq.ExpressionConverter.TypedTranslator1.Translate(ExpressionConverter parent, Expression linq) at System.Data.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq) at System.Data.Objects.ELinq.ExpressionConverter.Convert() at System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable1 forMergeOption) at System.Data.Objects.ObjectQuery1.GetResults(Nullable1 forMergeOption) at System.Data.Objects.ObjectQuery1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() at System.Data.Entity.Internal.Linq.InternalQuery1.GetEnumerator() at System.Data.Entity.Infrastructure.DbQuery1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at MvcMusicStore.Controllers.StoreManagerController.Index(String sortOrder) in

When trying this code

var albums = db.Albums.Include(a => a.Genre).Include(a => a.Artist);

            switch (sortOrder) {
                case "Artist desc":
                    albums = albums.OrderByDescending(o => o.Artist);
                    break;
                case "Title desc":
                    albums = albums.OrderByDescending(o => o.Title);
                    break;
                case "Title":
                    albums = albums.OrderBy(o => o.Title);
                    break;
                case "Genre desc":
                    albums = albums.OrderByDescending(o => o.Genre);
                    break;
                case "Genre":
                    albums = albums.OrderBy(o => o.Genre);
                    break;
                default:
                    albums = albums.OrderBy(o => o.Artist);
                    break;
            }

            return View(albums.ToList());

I cannot find a way to sort it.

  • 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-17T17:36:42+00:00Added an answer on June 17, 2026 at 5:36 pm

    You’re saying .Include(a => a.Artist); as well as .OrderByDescending(o => o.Artist);. If you’re trying to sort by an object Artist that would account for your error. You probably want something like this instead:

    albums = albums.OrderByDescending(o => o.Artist.Name);
    

    I’m assuming that an Artist has a String property Name, but maybe it’s called something different. The same would go for Genre:

    albums = albums.OrderByDescending(o => o.Genre.Name);
    

    In general, you need to sort by primitive values and not on entire objects.

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

Sidebar

Related Questions

I get this error when i play with the searchbar that I have just
i get this error System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException was thrown.` Why?? Kindly help
I get this error: Cannot initialize a parameter of type 'id<ZXingDelegate>' with an lvalue
I get this error message on my server: Method 'GetVirtualPath' in type 'System.Web.Http.WebHost.Routing.HostedHttpRoute' from
I get this error while accessing a php script: W/System.err: Error reading from ./org/apache/harmony/awt/www/content/text/html.class
I get this error when I run the code below. I have normally used
I get this error in my app { error: { message: Missing client_id parameter.,
I get this error becouse i am using ccnet and i don't have installed
i get this error in Visual studio 2008: Error 1 error C2664: 'BaseUtil::Type::CDouble::CDouble(const BaseUtil::Type::CDouble
I get this error when trying to have a WPF application try to format

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.