2009-04-09 25 views

回答

1

你有沒有看動態的LINQ?它應該做你想做的。看看這個來自scottgu的博客post

+0

謝謝。鏈接看起來不錯。 – ProfK 2009-04-10 10:25:21

0

如果您的數據是在xml中,linq to xml將允許您針對它編寫查詢,其中某些輸入是字符串。

例如:

System.Xml.Linq.XElement myData = GetData(); 

System.Xml.Linq.XElement result = new XElement("Result", 
    myData.Elements("Customer") 
    .GroupBy(e => e.Attributes("Name")) 
    .Select(g => new XElement("CustomerResult", 
    new XAttribute("Name" = g.Key, 
    new XAttribute("Count" = g.Count(), 
    new XAttribute("MinDate" = g.Min(e => e.Date) 
) 
);