class A{
public B body { get; set; }
}
class B{
public List<C> positions { get; set; }
}
class C{
public string NameOfWeek { get; set; }
}
class week{
public int ID { get; set; }
public string NameOfWeek { get; set; }
}
class SomeX{
public List<A> MapWeekID(List<week> weekList, List<A> AList)
{
foreach (var a in AList)
{
foreach (var position in a.body.positions)
{
position.NameOfWeek = weekList
.Where(x => x.NameOfWeek.ToString() == position.NameOfWeek)
.Select(y => y.NameOfWeek)
.FirstOrDefault();
}
}
return AList;
}
}
Here is code. How to write lambda for above foreach statement? I am trying but couldn't get hold of best solution so can anyone?
AList). I suggest keepingforeach