好的,假设您在一个名为的变量中有一个CorpSystem
对象列表,在一个名为 的变量中有一个对象Corpsystems
列表。尝试以下操作:AffectedSystem
AffectedSystems
编辑:要加入所有受影响的系统,试试这个:
var matches = from c in CorpSystems
join a in AffectedSystems on c.CorpSystemId equals a.CorpSystemId into ac
from subSystem in ac.DefaultIfEmpty()
select new
{
c.CorpSystemId,
c.SystemName,
Assigned = subSystem != null && subSystem.TaskItemId != null
};
或者仅针对 TaskItemId 为 1 的 AffectedSystems:
var matches = from c in CorpSystems
join a in AffectedSystems.Where(as => as.TaskItemId == 1)
on c.CorpSystemId equals a.CorpSystemId into ac
from subSystem in ac.DefaultIfEmpty()
select new
{
c.CorpSystemId,
c.SystemName,
Assigned = subSystem != null && subSystem.TaskItemId != null
};