描述:查询顾客的国家、城市和订单数信息,要求国家是法国并且订单数大于5
查询句法:
var 多条件 = from c inctx.Customers
where c.Country == "France" && c.Orders.Count > 5
select new
{
国家 =c.Country,
城市 =c.City,
订单数 =c.Orders.Count};
对应SQL:
SELECT [t0].[Country], [t0].[City], (
SELECT COUNT(*)
FROM [dbo].[Orders] AS [t2]
WHERE [t2].[CustomerID] = [t0].[CustomerID]
)AS [value]
FROM [dbo].[Customers] AS [t0]
WHERE ([t0].[Country] = @p0) AND (((
SELECT COUNT(*)
FROM [dbo].[Orders] AS [t1]
WHERE [t1].[CustomerID] = [t0].[CustomerID]
)) > @p1)
-- @p0: Input String (Size = 6; Prec = 0;Scale = 0) [France]
-- @p1: Input Int32 (Size = 0; Prec = 0; Scale = 0)[5]