This article is a mirror article of machine translation, please click here to jump to the original article.

View: 20672|Reply: 1

[Source] Make Linq's OrderBy support dynamic fields

[Copy link]
Posted on 4/10/2017 3:58:53 PM | | |

With linq's OrderBy, it's of course easy if you know exactly which field it is:


But what if we want to write a general method and don't know which field to sort in advance?

Searching on the Internet, there are many domestic blogs copying each other, swearing, but in fact, those codes can't run.

Or a good messenger of foreigners:
http://www.4byte.cn/question/33782/dynamic-orderby-using-linq-dynamic.html

I took it and modified it, and it can be used. The main idea is to extend Queryable. But there are many things in it that I can't understand.
Call:







Previous:Use of TransactionScope in C#
Next:.net/c# Google Protocol Buffers Quick Start
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com