【发布时间】:2015-06-26 15:40:56
【问题描述】:
我有一个包含 n 列的数据表。我想通过 LINQ 对数据表中的 n 列进行排序,但我不知道该怎么做。我用 1 列成功排序,但没有用多列排序
例如:
Dictionary<string, string> dict = Dictionary<string, string>
dict.Add("column_1", "asc");
dict.Add("column_2", "asc");
dict.Add("column_3", "asc");
...
dict.Add("column_n", "asc");
var Rows = from row in datatable.AsEnumerable()
orderby n1 acsending (I need loop to add all columns in Dictionary here to sort multi columns)
select row
如何循环 n 列以添加到 orderby 运算符中。
我的问题是用户有一个包含要排序的列名的数组,我需要循环一个数组以在运算符 orderby 中添加列名以对多列进行排序
PS:我的英文不好。对不起
谢谢 阮
【问题讨论】:
-
Multiple "order by" in LINQ 的可能重复项
-
我已经评论了我的问题的详细信息。请帮我解决它