model.SectionControlTabs.ForEach(x =>
{
x.EffectiveDate = x.EffectiveDate?.Split(' ')[0];
x.LinkedWorkControlEffectiveDate = x.EffectiveDate != null? model.WorkControls
.Where(y => DateTime.Parse(y.EffectiveDate) <= DateTime.Parse(x.EffectiveDate))
.OrderByDescending(y => DateTime.Parse(y.EffectiveDate))
.Select(y => new { CoverSelectionControl = y.CoverSelectionControl.ToString(),
UserSelectionControl = y.UserSelectionControl.ToString()})
.DefaultIfEmpty()
.First().ToString(): "";
});
CoverSelectionControl and UserSelectionControl are not passed to the same named fields of their SectionControlTab, I have tried two seperate select statements but the second cant see the UserSelectionControl and I also have another field I wish to copy. If call the x.LinkedWorkControl... again it will be a duplication.
Above using complex defined types I just need to read from a parent and update the children for a viewModel.
How do I update a number of fields without using new????