Wednesday, February 12, 2014

Update all items in a collection using Linq

collection = collection.Select(item => {item.PropertyToSet = value; return item;}).ToList();

or

users.ToList().ForEach(u =>
                      {
                         u.property1 = value1;
                         u.property2 = value2;
                      });

No comments:

Post a Comment