Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq - OrderBy the minimum value of two columns using lambda expressions?

I have an entity set that contains two DateTime properties. I want to order the set by the minimum value of the two properties. How can I do this with a lambda expression.

like image 880
kjv Avatar asked Dec 30 '22 07:12

kjv


1 Answers

myEntitySet.OrderBy(e => e.DateA < e.DateB ? e.DateA : e.DateB);
like image 69
Shawn Avatar answered Jan 01 '23 16:01

Shawn