Mike Wills
Mike Wills

Reputation: 21275

Order by on EF not working as I had hoped

How do I get this to work properly? I want order by duedate desc, type

I currently have:

billSummaryRepository.GetBillSummaries(logIn.CustomerNumber)
    .OrderByDescending(o => o.DueDate)
    .OrderBy(o => o.Type)

This works:

BillSummaries = billSummaryRepository.GetBillSummaries(logIn.CustomerNumber)
    .OrderBy(o => o.Type)
    .OrderByDescending(o => o.DueDate)

but how dangerous is that? Will it work?

Upvotes: 0

Views: 531

Answers (1)

kenwarner
kenwarner

Reputation: 29130

BillSummaries = billSummaryRepository
    .GetBillSummaries(logIn.CustomerNumber)
    .OrderByDescending(o => o.DueDate)
    .ThenBy(o => o.Type);

Upvotes: 2

Related Questions