Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sort on discriminator - EF

I have a model where I am using a discriminator. As I cannot share the original code, here is a mockup

public class Dog {}

public class SomeDog : Dog {}

Now I want my entities to be sorted by the Discriminator, having SomeDog first and only after these, having my Dog entities.

Is there any way to actually sort on my Discriminator? Or do I have to find a workaround?

like image 624
Tikkes Avatar asked Jul 01 '13 09:07

Tikkes


1 Answers

Have you tried sort when you read list of context?

Example:

YourContext.Dogs.OrderBy(d => (d is SomeDog) ? 1 : 2)
like image 119
ígor Avatar answered Sep 23 '22 08:09

ígor