You can create a small class (object) which will hold your result values. You can fill the class at run-time from the IEnumerable<T> set the query returns. Then, bind the object, directly to the datagrid using ItemsSource property.
public class MyClass
{
public string Name {get; set;}
public DataTime DOB {get; set;}
}
/* Create a strong typed collection of the class */
List<MyClass> myList = new List<MyClass>();
Now, iterate through the IEnumerable<T> collection you get from the query. Each row can be an instance of "Myclass".
foreach (IEnumerable<Graphic> graphic in your-querry-result)
{
MyClass myObject = new MyClass(); // one instance for each row
myObject.Name = graphic.Attributes["Name"];
myObject.DOB = graphic.Attributes["DOB"];
/* Add filled class instance (a row) to collection */
myList.Add(myObject);
}
/* Bind your strong-type collection to the datagrid */
myDatagrid.ItemsSource = myList;
Note:
In light of simplicity I hard-coded the column names. You do not have to, really. You can use Reflection to match the column name and data type to that of the class "MyClass". In this scenario, you will need another foreach inner loop to iterate through every column of each row:
foreach (object attribute in graphic.Attributes)
{
/* now use Reflection to expose every property of "attribute" */
}
If this is your case, I can be more specific about Reflection, if needed.
Hope this helps....
Hugo.