Reputation: 7342
I have a MVC application that I'm near completing. But I have a situation that cannot figure out the syntax for.
What I want to do is to sort on two columns When I use the syntax below, it sorts by one column, then the next.
public IQueryable<vw_FormIndex> FindAllFormsVw(int companyIdParam)
{
return _db.vw_FormIndexes.Where(d => d.companyID == companyIdParam).OrderBy(d => d.formSortOrder).OrderBy(d => d.formCustNumber);
}
Suggestions Please
Upvotes: 3
Views: 1832
Reputation: 75557
Maybe ThenBy
?
_db.vw_FormIndexes.Where(d => d.companyID == companyIdParam).OrderBy(d => d.formSortOrder).ThenBy(d => d.formCustNumber);
Upvotes: 0
Reputation: 2082
I think you want ThenBy
public IQueryable<vw_FormIndex> FindAllFormsVw(int companyIdParam)
{
return _db.vw_FormIndexes.Where(d => d.companyID == companyIdParam).OrderBy(d => d.formSortOrder).ThenBy(d => d.formCustNumber);
}
More on ThenBy operator here.
Good luck!
Upvotes: 5