2012-09-12 120 views

回答

0

以下查詢

var grouping = elements.GroupBy(e => (string)e.Attribute("ID"))); 

將按屬性ID對所選元素進行分組。


或者您只需要ID?不同?

var ids = elements.Select(e => (string)e.Attribute("ID")).Distinct(); 
0
var xmlSource = contacts.Load(@"../../Contacts.xml"); 


var q = from c in xmlSource.User 
     where c.ID in (from c2 in xlsource.User select c.id).distict().tolist() 
     select c; 

你必須做這樣的事情