请帮助我将以下命令转换为等效的lambda
Select t1.id, t1.fullname
From t1
Where t1.id in (Select t2.id From t2 Where t2.bNo = 5))
答案 0 :(得分:0)
您可以尝试将linq where
与Any
一起使用。
var result = t1.Where(x => t2.Any(x1 => x1.Id == x.Id && x1.bNo == 5))
.Select(x => new { x.Id, x.fullName });
答案 1 :(得分:0)
您可以在表达式中尝试contains
。
var IdListQuery = context.t2.where(c=> c.bNo == 5).select(s=> s.id);
var query = context.t1.where(c=>IdListQuery.contains(c.id)).select(s=> s.id, s.fullname);