CipherIS
asked on
C# Linq Update One List<T> with values from another List<T>
I want to updated the LeadTime field in ComponentModel from LeadTimeModel where the PartNo's match. They are both List<T>.
public class ComponentsModel
{
public string PartNo { get; set; }
public string Cost { get; set; }
public string LeadTime { get; set; }
}
public class LeadTimeModel
{
public string PartNo { get; set; }
public long LeadTime { get; set; }
}
ASKER
I had below.
_leadtimemodel.ForEach(x => _componentsmodel.First(y => y.PartNo == x.PartNo).LeadTime = x.LeadTime.ToString());
Problem occurred when a PartNo didn't match. Didn't think I would run into a prob as I'm looking for PartNo's that match.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Saige!
Open in new window
Result: