public static class PHVExtensions
{
public static IEnumerable<T> SetValue<T>(this IEnumerable<T> items, Action<T>
updateMethod)
{
foreach (T item in items)
{
updateMethod(item);
}
return items;
}
}
/*
With that method in place, I can write my statement like this:
customers.Where(c => c.IsValid).SetValue(c => c.CreditLimit = 1000).ToList();
Or like this:
var newCustomers = customers.Where(c => c.IsValid).SetValue(c => c.CreditLimit = 1000);
Or like this for Entity Framework:
db.Customers.Where(c => c.IsValid).ToList().SetValue(c => c.CreditLimit = 1000);
*/