此语句的LINQ TO SQL或SQL服务器语法是什么
Select ProductName
from Products
where ProductId = (Select ProductId
from OrderAndProducts
where OrderID = 5 )
答案 0 :(得分:1)
在Linq To Sql中
int orderId = 5;
var result = (From p in context.Products
join op in context.OrderAndProducts on p.ProductId equals op.ProductId
where op.OrderId == orderId
select p.ProductName).ToList();
context将是来自linqToSql的数据上下文。
我不太确定您对SQL Server语法的意思 - 该查询是否已经有效?