EF中的Select * From T Where id In(xxx,xxx)子查询
//使用子查询
//SQL: Select * From KB_BOMTable Where PartNo in (Select PartNO From KB_MPS Where MPSId='00001')
var q1=DBCtx.KB_BOMTable.Where(ent =>
DBCtx.KB_MPS.Where(t => t.MPSId == MPSId).Select(t => t.PartNo).Contains(ent.PartNo)
);
var list= q1.ToList();
//使用数组
//SQL:Select * From KB_BOMTable Where PartNo in ('xx01','xxx02')
string[] partnoArr=MPSList.Select(mps =>mps.PartNo).ToArray();
var q=DBCtx.KB_BOMTable.Where(ent => partnoArr.Contains(ent.PartNo));
var rootBOM= q.ToList();