I am using “Linq” to filter list of objects and to sort them, like
myList.Where(x => x.Item!= "SF" && x.AdSize == minadSize)
.OrderBy(x => x.ManufacturingDate)
.OrderBy(x=>x.ExpiryDate);
I doubt whether i am doing it right or not that is if i want to “sorting” on multiple fields then is it necessary to use multiple Order By clause cant it be done with single “OrderBy”
Don’t use multiple
OrderBycalls – useOrderByfollowed byThenBy:If you use
OrderBytwice, it will reorder the already-ordered-by-date list by expiry-date, whereas I assume you only want to order by expiry date for items with an equal manufacturing date, which is what the above does.Obviously there’s a
ThenByDescendingmethod too. For example: