当我使用以下代码时,我会多次获得相同的项目。
我希望获得唯一的项目。我看到了一个Stack Overflow的帖子,如何使用LINQ进行SELECT UNIQUE?,它使用了这个方法,我尝试实现它,但是改变没有任何影响。
代码:
XElement neededFiles = new XElement("needed",
from o in _9nFiles.Elements()
join t in addedToSitePull.Elements()
on o.Value equals
t.Value
where o.Value == t.Value
select new XElement("pic", o.Value));
我希望获得唯一的项目。我看到了一个Stack Overflow的帖子,如何使用LINQ进行SELECT UNIQUE?,它使用了这个方法,我尝试实现它,但是改变没有任何影响。
代码:
XElement neededFiles = new XElement("needed",
(from o in _9nFiles.Elements()
join t in addedToSitePull.Elements()
on o.Value equals
t.Value
where o.Value == t.Value
select new XElement("pic", o.Value)).Distinct() );