What is LINQ equivalent of SQL’s “IN” keyword

后端 未结 4 1677
暗喜
暗喜 2021-01-05 00:22

How can I write below sql query in linq

select * from Product where ProductTypePartyID IN
(
    select Id from ProductTypeParty where PartyId = 34
)
<         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-05 01:22

    Something similar to this

    var partyProducts = from p in dbo.Product 
                        join pt in dbo.ProductTypeParty on p.ProductTypePartyID equal pt.PartyId 
                        where pt.PartyId = 34 
                        select p
    

提交回复
热议问题