I need to update all the properties in a list object using linq.
For ex.: I have an User List with (Name, Email, PhoneNo,...) as properties.
I will get the Users List(List<Users>) from database which is filled with all properties except Email. I need to update all the Email property in the list after retrieving from database with some email in session.
How can i do it?
You should be able to do it simply via ForEach..
users.ForEach(user => user.email = sessionEmail);
or for multiple properties..
users.ForEach(user =>
{
user.email = sessionEmail;
user.name = "Some Person";
...
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With