Update all objects in a collection using LINQ
Update all objects in a collection using LINQ
Update all objects in a collection using LINQ
Re: Update all objects in a collection using LINQ
While you can use a `ForEach` extension method, if you want to use just the framework you can do
```
collection.Select(c => {c.PropertyToSet = value; return c;}).ToList();
```
The `ToList` is needed in order to evaluate the select immediately due to *lazy evaluation*.
```
collection.Select(c => {c.PropertyToSet = value; return c;}).ToList();
```
The `ToList` is needed in order to evaluate the select immediately due to *lazy evaluation*.