tags:

views:

82

answers:

2

I assume I need to use the method call syntax instead of the query expression form, and I know the basics of grouping in the latter. Maybe some gurus can give caveats and advice on using group fields and aggregates obtained at runtime from a configuration, for use in a reporting like structure.

A: 

If your data is in xml, linq to xml would allow you to write queries against it in which the certain inputs are strings.

For example:

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)
  )
 );
David B
+1  A: 

Have you looked at Dynamic Linq? It should do what you want. Have a look at this post from scottgu's blog.

Christopher Edwards
Thanks. The link looks good.
ProfK