我有2 IEnumerable<XPathNavigator>
,我想按子值对其进行排序。
item1 = from XPathNavigator item in iterator1 select item;
item2 = from XPathNavigator item in iterator2 select item;
item1 = item1.Union(item2);
item1.OrderBy(res => int.Parse(GetNavigatorValue(res, "./item[@value='ParentId']")));
static string GetNavigatorValue(XPathNavigator iterator, string xpath)
{
XPathNodeIterator inner = iterator.Select(xpath);
inner.MoveNext();
return inner.Current.Value;
}
它不起作用。
如果需要按xpath对其进行排序,如何在Linq中使用OrderBy
?
谢谢, user460397
答案 0 :(得分:0)
这是问题吗?不应该是
item1 = item1.OrderBy( ... );