在下面的代码中,我希望 retrn n 行,但它总是返回零行,因为我的初始集有零记录。理想情况下,它应该执行 UNION ALL 并返回整数列表中所有整数的记录 clearTotals{6,7,8,9,17} 知道如何去做吗?
var tbl = (from a in db.Applicants
where a.Id == null
select new { a.Id, a.Firstname, a.Lastname });
int thisTag;
foreach (int c in clearanceTotals)
{
switch (c)
{
case 6:
thisTag = 38;
break;
case 8:
thisTag = 39;
break;
case 17:
thisTag = 39;
break;
case 7:
thisTag = 42;
break;
case 9:
thisTag = 44;
break;
}
tbl = (from a in db.Applicants
join ad in db.ApplicantDeployments on a.Id equals ad.ApplicantId
join aa in db.ApplicantAttachments on a.Id equals aa.ApplicantId
where a.Nationality == 15 && a.DoNotUse == false && a.ClearanceStatus == c
&& aa.Tag == thisTag
select new { a.Id, a.Firstname, a.Lastname }).Union(tbl);
}