Reputation: 24562
I have this LINQ statement:
db.PhraseCategories.OrderBy(c => c.Name);
I would like to order first by GroupId and then second by Name.
Can anyone give me advice on how I can do this?
Upvotes: 0
Views: 44
Reputation: 16956
You could use ThenBy
extension method to performs a subsequent ordering of the elements in a sequence in ascending order according to a key
.
db.PhraseCategories
.OrderBy(c => c.GroupId)
.ThenBy(c => c.Name);
Or
from c in db.PhraseCategories
orderby c.GroupId, c.Name
Upvotes: 4