ToList().ForEach in Linq

后端 未结 8 885
攒了一身酷
攒了一身酷 2020-12-04 09:13

I am new to Linq.

I want to set two values in foreach statement like this

My actual code is this

foreach (Employee emp in employees         


        
8条回答
  •  一向
    一向 (楼主)
    2020-12-04 09:50

    Try with this combination of Lambda expressions:

    employees.ToList().ForEach(emp => 
    {
        collection.AddRange(emp.Departments);
        emp.Departments.ToList().ForEach(dept => dept.SomeProperty = null);                    
    });
    

提交回复
热议问题