LINQ OrderBy / ThenBy with conditional sorting in C#

Rahul Kiwitech
Rahul K...
292 Points
26 Posts

I am trying to sort list by date on some condition to other property. List has EventDate and EventStatus. EventStatus has fixed values like 'Live','Save','Guest','Past'. I want sorting as

When EventStatus=="Live"  || EventStatus=="Save" || EventStatus=="Guest"
Sort as EventDate descending
When EventStatus=="Past"
Sort as EventDate ascending

Is this possible to sort list like this?

Views: 11124
Total Answered: 0
Total Marked As Answer: 0
Posted On: 28-Feb-2017 22:16

Share:   fb twitter linkedin
Answers
 Log In to Chat