我正在尝试使用 LINQ 重写以下内容
foreach (WMCommon.Services.StakeOut.assembly ass in assemblies)
{
foreach (var agg in aggregate)
{
if ( agg.catagory.unitActn == ass.unitActn &&
agg.catagory.unitCode == ass.unitCode &&
agg.catagory.unitLength == ass.unitLength
)
{
ass.quantity = agg.qty;
}
}
}
据我所知:
assemblies.Where( 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)));
提前感谢您的帮助。我希望 LINQ 会比嵌套 FOREACH 快得多?