Convert Nested Foreach to Linq

前端 未结 3 1965
情书的邮戳
情书的邮戳 2021-01-20 01:39

I am trying to re-write the following using LINQ

foreach (WMCommon.Services.StakeOut.assembly ass in assemblies) 
{
  foreach (var agg in aggregate) 
  {
           


        
3条回答
  •  深忆病人
    2021-01-20 02:05

    Try this:

    assemblies.ForEach(a => a.quantity = (aggregate.Where(p => p.catagory.unitActn == a.unitActn && p.catagory.unitCode == a.unitCode && p.catagory.unitLength == a.unitLength).Select(s=>s.qty)));
    

    But mind it it wouldn't be faster

提交回复
热议问题