tags:

views:

13

answers:

0

Most of the examples I've found deal with Linq to entities, which is not what I need. I have a standard DataTable which I need to modify before returning to the caller. I can iterate over the normal Table.Rows collection or do something like this with the new extension methods:

foreach (var x in table.AsEnumerable()) {
    if (x.Field<int>("SomeField") > SomeValue)
        x.SetField<string>("OtherField", "OtherValue");
}

But I'm still manually looping through the entire row collection. Not necessarily a big deal, but I'm wondering if there's a more elegant way to accomplish this with Linq somehow, in the sense that I need to create an expression that iterates over the results of a query and performs an arbitrary action, rather than just select elements from the container being enumerated.