Entity Framework Order by descending by row field in query

c# entity-framework linq

Question

I want to create an EF query that does condition-based ascending or descending ordering. The pseudocode I use is as follows:

  var result= q.OrderByDescending(x => x.StatusId == 3)
                    then if( x.StatusId == 3) 
                          then order by x.ReserveDate
                     else
                          then order by descending x.LastUpdateDate

How can I go about this?

1
3
7/31/2017 10:14:08 AM

Popular Answer

ZZZ_tmp
4
7/31/2017 10:18:33 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow