你好我不清楚为什么我的linq语句orderby
没有按预期工作。
var q = from DirectoryInfo subDirectory
in item.GetDirectories()
orderby (item.Name == "TableDefinition" ? 1 : 2), item.Name
select subDirectory;
foreach (DirectoryInfo subDirectory in q)
{
Execute(subDirectory);
}
我希望首先通过查看名称是" TableDefinition"来排序项目。或者不是,其次是名字。
它似乎只按名称排序,按字母顺序递增。
答案 0 :(得分:3)
您必须使用["1"]
["12"]
["1", "23"]
["1", "2", "34"]
["12", "3", "45"]
["1", "23", "4", "56"]
["12", "3", "45", "6", "78"]
["1", "23", "4", "56", "7", "89"]
["1", "2", "34", "5", "67", "8", "90"]
代替subDirectory
item