我有如下SQL语句
SELECT [CodeHouse]
,[CodeReq]
,[Address]
FROM [ShahrdariProject].[dbo].[House]
where [CodeReq] in
(select [CodeReq] From [ShahrdariProject].[dbo].[HouseOwner] where [Name] = 'Alex' )
谁能帮我把这个语句转换成 LINQ?
最佳答案
此 SQL:
SELECT [CodeHouse]
,[CodeReq]
,[Address]
FROM [ShahrdariProject].[dbo].[House]
where [CodeReq] in
(select [CodeReq] From [ShahrdariProject].[dbo].[HouseOwner]
where [Name] = 'Alex' )
相当于这个 Linq:
var q = from h in db.Houses
where db.HouseOwners.Any(x => x.Name == "Alex" && x.CodeReq == h.CodeReq)
select h;
关于c# - 如何将此 T-SQL 转换为 LINQ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11389204/