我有一个查询如下,它返回服务器名称和组件名称的列表
string match = "TEST"
var headerArray = from a in this.db.Servers
where a.ServerID.Contains(match)
join b in this.db.Components
on a.ServerID equals b.ServerID into g
select new
{
a.ServerID,
Components = g.Select(x => x.Name),
};
List<string> result = new List<string>();
foreach (var server in headerArray)
{
result.Add(server.ServerID);
foreach (var componentName in server.Components)
result.Add(componentName);
}
string[] header = result.ToArray();
编辑
datagrid1.ItemsSource = header.ToList();
header 以数组的形式存储服务器名称列表。如何将此结果绑定到数据网格列?