Linq to sql :查询句法--in 操作

来源:互联网 发布:linux 查看syslog 编辑:程序博客网 时间:2024/05/16 05:05

描述:查询指定城市中的客户

查询句法: 

var in操作 = from c in ctx.Customers

where new string[] {"Brandenburg","Cowes",

"Stavern" }.Contains(c.City)

select c;

对应SQL

      SELECT [t0].[CustomerID], [t0].[CompanyName], [t0].[ContactName],

[t0].[ContactTitle], [t0].[Address],[t0].[City], [t0].[Region], [t0].[PostalCode], [t0].[Country],

[t0].[Phone], [t0].[Fax]

FROM [dbo].[Customers] AS [t0]

WHERE [t0].[City] IN (@p0, @p1, @p2)

-- @p0: Input String (Size = 11; Prec = 0;Scale = 0) [Brandenburg]

-- @p1: Input String (Size = 5; Prec = 0;Scale = 0) [Cowes]

-- @p2: Input String (Size = 7; Prec = 0;Scale = 0) [Stavern]


原创粉丝点击