[英]xml linq orderby clause not working how it should be
我遇到了orderby子句的问题。
IEnumerable<XElement> elList =
from el in doc.Descendants("Department1").Descendants("Course")
orderby el.Attribute("Course_Code").Value ascending
select el;
我用foreach和messagebox试了一下。 消息框显示它发现的内容:100,150,170,40,60,80而不是40,60,80,10,150,170。当我使用降序子句时,它会以相反的方式做同样的事情。
你应该订购整数值而不是字符串
from el in doc.Descendants("Department1").Descendants("Course")
orderby (int)el.Attribute("Course_Code") ascending
select el;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.