Sir / Ma'我想将下面提到的SQL查询转换为LINQ,我该如何实现。
select * from dbo.Main as M
where M.ApplicationId in
(select distinct R.ApplicationId from tblRecomSanctionedDetail R
where R.UpdateByUserId = 1011 )
尝试使用我对LINQ的有限知识,但无法获得输出。
答案 0 :(得分:1)
我目前没有任何地方可以对此进行测试,但我认为它大概会像......
var applicationIds = tblRecomSanctionedDetailQueryable.Where(x => x.UpdateByUserId == 1011).Select(x => x.ApplicationId);
var result = mainQueryable.Where(x => applicationIds.Contains(x.ApplicationId)).ToList();