Is het mogelijk, en zo ja hoe, om de resultaten van een LINQ-query door te lussen?
Iets zoals dit:
var results= from a in dt.AsEnumerable()
where a.Field("id") == i
select new
{
id= a.Field("id"),
a= a.Field("a"),
b = a.Field("b")
};
IEnumerable colNames = results.First().GetType().GetProperties()
.Select(p => p.Name);
string[] columns = colNames.ToArray();
int i = 0;
foreach (var row in results)
{
for (int i = 0; i < columns.Count(); i++)
{
string foobar = (string)row[columns[i]];
i++;
}
}
In essentie wil ik het volgende soort functionaliteit repliceren:
DataRow dr = new DataRow();
string foobar = dr[columns[i];
Alvast bedankt.