LINQ using OrderBy and ThenBy

By TSN ...

Multiple Order By Using Linq i.e using Order by with more than one Variable...


The Linq Porvides custom sorting on Collection binding it to a GUI control in the middle tier of the application itself

var res = us.Friends_User.OrderBy(fu => fu.User_Friend.DateOfBirth.Value.Month).ThenBy(fu =>                                                                           fu.User_Friend.DateOfBirth.Value.Day);

In the above Example we have taken a collection having the Friends Userinformation which consists Friends Birth day , so here we are first using order by month and after getting the order by month ,from the result set we are again arranging it by day wise.

Related FAQs

Multiple Order By Using Linq i.e using Order by with more than one Variable...
LINQ using OrderBy and ThenBy  (874 Views)