4

how can I do multiple sort in

 return (from p in _db.Pages where p.int_PostStatusId == 2 select p).OrderByDescending(m => m.int_SortOrder);

i want to do order by by int_PageId as well? first by int_SortOrder then by int_PageId

1 Answer 1

14

Use either ThenBy or ThenByDescending to order the result of an OrderBy or OrderByDescending:

return (...)
    .OrderByDescending(m => m.int_SortOrder)
    .ThenBy(m => m.int_PageId);

Or using the query syntax:

orderby p.int_SortOrder descending, p.int_PageId
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.