As far as I think,you must use orderby before using Thenby.
I don't understand your requirment clearly.Do you haven't know which field you have?If you have Id and Phone,you could orderby Id then by phone.
Could you tell us more details of your requirment?
Best regards,
Yijing Sun
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
59 Points
197 Posts
dynamic sorting
Jul 31, 2020 03:54 PM|amithashenoy|LINK
HI,
i want to query result and display in order based on Id,Nam,Phone and Email can anyone help me how to do it. expected result
below is sample code which results in
Thanks and Really appreciate your help
All the Best . Please 'Mark this Post as Answer ' if it helps you.
Participant
1620 Points
927 Posts
Re: dynamic sorting
Aug 01, 2020 12:38 AM|PaulTheSmith|LINK
I'm not 100% sure what you are trying to do but, for example, change the case "name" to
orderExpression = orderExpression.ThenBy(a => a.Name)
should compound your queries.
Member
59 Points
197 Posts
Re: dynamic sorting
Aug 01, 2020 06:05 AM|amithashenoy|LINK
Yes, when i try to do that
orderExpression = orderExpression.ThenBy(a => a.Name), gives error saying Then by is not supported in
Func<IQueryable<T>, IOrderedQueryable<T>>
All the Best . Please 'Mark this Post as Answer ' if it helps you.
Contributor
3730 Points
1412 Posts
Re: dynamic sorting
Aug 04, 2020 07:00 AM|yij sun|LINK
Hi amithashenoy,
As far as I think,you must use orderby before using Thenby.
I don't understand your requirment clearly.Do you haven't know which field you have?If you have Id and Phone,you could orderby Id then by phone.
Could you tell us more details of your requirment?
Best regards,
Yijing Sun