3

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

3 Answers 3

5

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!

Sign up to request clarification or add additional context in comments.

Comments

3

Use .OrderBy().ThenBy();

Comments

0

Maybe ThenBy?

_db.vw_FormIndexes.Where(d => d.companyID == companyIdParam).OrderBy(d => d.formSortOrder).ThenBy(d => d.formCustNumber);

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.