Reassign the list, ideally without mutating anything. This would be more consistent with the functional programming mindset of LINQ.
IEnumerable<MyObj> myList1 = EF.GetList(etc);
IEnumerable<MyObj> myList2 = myList1.Select( x =>
new MyObj
{
uploadedAt = MyUtils.ConvertToLocalTime(x.uploadedAtUTC, x.clientTimezone),
anyOtherFields = x.anyOtherFields
}
).ToList();
If constructing a MyObj
is complicated and/or you really need to mutate it, you can also do this:
IEnumerable<MyObj> myList = EF.GetList(etc);
myList = myList.Select( x => {
x.uploadedAt = MyUtils.ConvertToLocalTime(x.uploadedAtUTC, x.clientTimezone);
return x;
}).ToList();
But if you're going to do it that way, you may as well use the for
loop.