sql-server – 什么是LINQ相当于SQL的“IN”关键字
发布时间:2021-03-30 23:14:16 所属栏目:MsSql 来源:互联网
导读:我怎样才能在 linq中编写下面的sql查询 select * from Product where ProductTypePartyID IN( select Id from ProductTypeParty where PartyId = 34) 除了语法变化之外,您可以用几乎相同的方式编写它. from p in ctx.Productwhere (from ptp in ct
我怎样才能在 linq中编写下面的sql查询 select * from Product where ProductTypePartyID IN ( select Id from ProductTypeParty where PartyId = 34 ) 解决方法除了语法变化之外,您可以用几乎相同的方式编写它.from p in ctx.Product where (from ptp in ctx.ProductTypeParty where ptp.PartyId == 34 select ptp.Id).Contains(p.ProductTypePartyID) select p 我更喜欢使用存在量词,但是: from p in ctx.Product where (from ptp in ctx.ProductTypeParty where ptp.PartyId == 34 && ptp.Id == p.ProductTypePartyID).Any() select p 我希望这个表单将解析为生成的SQL中的EXISTS(SELECT * …). 如果性能有很大差异,您需要对两者进行分析. (编辑:台州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- sql-server – SQL Server 2014备份到2012年
- SQL Server 提取数字、提取英文、提取中文的sql语
- SQLite Delete详解及实例代码
- sql-server – Visual Studio和SQL Server – 正
- SQL server 使用 内联结(INNER JOIN) 联结多个表
- sql-server – 如何从Sql Server中的Server Admi
- SqlServer2012中First_Value函数简单分析
- SqlServer修改数据库文件及日志文件存放位置
- SQL Server中NULL的正确使用与空间占用
- sqlserver2008 拆分字符串
热点阅读