February 27, 2009

EntitySqlException: “The ORDER BY sort key(s) type must be order-comparable.”

Filed under: Uncategorized — Tags: , , , — yasi8h @ 8:42 am

Think: In the Entity Framework…

you have two models like this:

Item{ID, Name, Category}, Category{ID, Name}

With a Relationship like this:

Item belongs to a Category. and a Category may have zero or more Items.

if you try to sort the Items by their Category(which doesn’t make sense in the first place! :P) by doing something like:


you would get the error that is specified in the title of this post. .

but if all you want to do is sort all the Items by the Name of their respective Categories. you should do something like this:


it will work just fine. you can use this doted notation to specify properties of properties(nested properties). this can be used with OrderBy’s Where caluses…etc this is a faily simple thing i know 🙂 but it was bit tricky to find this out, for me atleast.


Blog at