与LINQ相关的子查询SQL
请帮助我将上述查询转换为LINQ。请尝试以下方法 LINQ中没有“In”子查询(到目前为止) 使用“Any”操作符完成相同的操作 例如: 与员工位于同一城市的所有客户与LINQ相关的子查询SQL,sql,.net,linq,subquery,correlated-subquery,Sql,.net,Linq,Subquery,Correlated Subquery,请帮助我将上述查询转换为LINQ。请尝试以下方法 LINQ中没有“In”子查询(到目前为止) 使用“Any”操作符完成相同的操作 例如: 与员工位于同一城市的所有客户 select * from Table1 where TC in (select TC from Table2 where Application in ('AAA'))` 或 .Any()运算符的左侧是子查询 from c in db.Custo
select *
from Table1
where TC in (select TC
from Table2
where Application in ('AAA'))`
或
.Any()运算符的左侧是子查询
from c in db.Customers
where db.Employees.Any(e => e.City == c.City)
select c;
相当于SQL
query.Any(x => predicate)
在这里获取更多详细信息
不带
在('AAA')中的应用程序这看起来很简单:
EXISTS(
SELECT *
FROM query
WHERE predicate
)
更新(我错得多厉害啊!)
List myCollection=新列表{“AAA”};
从表1s中的t1开始
其中db.Table2s.where(t2=>myCollection.Contains(t2.Application)).Select(t2=>t2.TC).Contains(t1.TC)
从表1s中的t1开始
应该在代码集合中使用。粘贴映射类的代码谢谢,对我来说很好:-)
from t1 in db.Table1s
where db.Table2s.Select(t2 => t2.TC).Contains(t1.TC)
from t1 in db.Table1s
List<string> myCollection = new List<string> { "AAA" };
from t1 in db.Table1s
where db.Table2s.Where(t2 => myCollection.Contains(t2.Application)).Select(t2 => t2.TC).Contains(t1.TC)
from t1 in db.Table1s