Change a field in a table using linq

advertisements

I have an array of objects, where one field is a boolean field called includeInReport. In a certain case, I want to default that to always be true. I know it's as easy as doing this:

foreach (var item in awards)
{
    item.IncludeInReport = true;
}

But is there an equilivent way to do this with linq? It's more to satisfy my curiosity then anything... My first thought was to do this...

awards.Select(a => new Award{ IncludeInReport = true, SomeFiled = a.SomeField, .... }

But since I have a few fields in my object, I didn't want to have to type out all of the fields and it's just clutter on the screen at that point. Thanks!


ForEach is sort of linq:

awards.ForEach(item => item.IncludeInReport = true);

But Linq is not about updating values. So you are not using the right tool.


Let me quantify "sort of linq". ForEach is not Linq, but a method on List<T>. However, the syntax is similar to Linq.