首页 > Linux操作系统 > Linux操作系统 > In & Like操作
string[] customerID_Set = new string[] { "AROUT", "BOLID", "FISSA" };
var q = (from o in db.Orders
where customerID_Set.Contains(o.CustomerID)
select o).ToList();
SELECT [t0].[OrderID], [t0].[CustomerID], [t0].[EmployeeID], [t0].[OrderDate], [
t0].[RequiredDate], [t0].[ShippedDate], [t0].[ShipVia], [t0].[Freight], [t0].[Sh
ipName], [t0].[ShipAddress], [t0].[ShipCity], [t0].[ShipRegion], [t0].[ShipPosta
lCode], [t0].[ShipCountry]
FROM [dbo].[Orders] AS [t0]
WHERE [t0].[CustomerID] IN (@p0, @p1, @p2)
-- @p0: Input String (Size = 5; Prec = 0; Scale = 0) [AROUT]
-- @p1: Input String (Size = 5; Prec = 0; Scale = 0) [BOLID]
-- @p2: Input String (Size = 5; Prec = 0; Scale = 0) [FISSA]
var q = (from o in db.Orders
where (new string[] { "AROUT", "BOLID", "FISSA" }).Contains(o.CustomerID)
select o).ToList();
var q2 = (from o in db.Orders
where !(new string[] { "AROUT", "BOLID", "FISSA" }).Contains(o.CustomerID)
select o).ToList();
Selec * from table where id like '%AD%'
Selec * from table where id like '%AD'
Selec * from table where id like 'AD%'
var q = (from c in db.Customers
where c.CustomerID.Contains("ROUT")
select c).ToList();
SELECT [t0].[CustomerID], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactT
itle], [t0].[Address], [t0].[City], [t0].[Region], [t0].[PostalCode], [t0].[Coun
try], [t0].[Phone], [t0].[Fax]
FROM [dbo].[Customers] AS [t0]
WHERE [t0].[CustomerID] LIKE @p0
-- @p0: Input String (Size = 6; Prec = 0; Scale = 0) [%ROUT%]
var q = (from c in db.Customers
where c.CustomerID.EndsWith("ISSA")
select c).ToList();
SELECT [t0].[CustomerID], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactT
itle], [t0].[Address], [t0].[City], [t0].[Region], [t0].[PostalCode], [t0].[Coun
try], [t0].[Phone], [t0].[Fax]
FROM [dbo].[Customers] AS [t0]
WHERE [t0].[CustomerID] LIKE @p0
-- @p0: Input String (Size = 5; Prec = 0; Scale = 0) [%ISSA]
var q = (from c in db.Customers
where c.CustomerID.StartsWith("ARO")
select c).ToList();
SELECT [t0].[CustomerID], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactT
itle], [t0].[Address], [t0].[City], [t0].[Region], [t0].[PostalCode], [t0].[Coun
try], [t0].[Phone], [t0].[Fax]
FROM [dbo].[Customers] AS [t0]
WHERE [t0].[CustomerID] LIKE @p0
-- @p0: Input String (Size = 4; Prec = 0; Scale = 0) [ARO%]
var q = (from c in db.Customers
where SqlMethods.Like(c.CustomerID, "%ROUT%")
select c).ToList();
var q = (from c in db.Customers
where SqlMethods.Like(c.CustomerID, "%ISSA")
select c).ToList();
var q = (from c in db.Customers
where SqlMethods.Like(c.CustomerID, "ARO%")
select c).ToList();
var q = (from c in db.Customers
where SqlMethods.Like(c.CustomerID, "A%O%T")
select c).ToList();
SELECT [t0].[CustomerID], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactT
itle], [t0].[Address], [t0].[City], [t0].[Region], [t0].[PostalCode], [t0].[Coun
try], [t0].[Phone], [t0].[Fax]
FROM [dbo].[Customers] AS [t0]
WHERE [t0].[CustomerID] LIKE @p0
-- @p0: Input String (Size = 5; Prec = 0; Scale = 0) [A%O%T]| Wildcard character | Description | Example |
|---|---|---|
| % | Any string of zero or more characters. | WHERE title LIKE '%computer%' finds all book titles with the word 'computer' anywhere in the book title. |
| _ (underscore) | Any single character. | WHERE au_fname LIKE '_ean' finds all four-letter first names that end with ean (Dean, Sean, and so on). |
| [ ] | Any single character within the specified range ([a-f]) or set ([abcdef]). | WHERE au_lname LIKE '[C-P]arsen' finds author last names ending with arsen and beginning with any single character between C and P, for example Carsen, Larsen, Karsen, and so on. |
| [^] | Any single character not within the specified range ([^a-f]) or set ([^abcdef]). | WHERE au_lname LIKE 'de[^l]%' all author last names beginning with de and where the following letter is not l. |
var q = (from c in db.Customers
where SqlMethods.Like(c.CustomerID, "A_O_T")
select c).ToList();
SELECT [t0].[CustomerID], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactT
itle], [t0].[Address], [t0].[City], [t0].[Region], [t0].[PostalCode], [t0].[Coun
try], [t0].[Phone], [t0].[Fax]
FROM [dbo].[Customers] AS [t0]
WHERE [t0].[CustomerID] LIKE @p0
-- @p0: Input String (Size = 5; Prec = 0; Scale = 0) [A_O_T]
var q = (from c in db.Customers
where !SqlMethods.Like(c.CustomerID, "A_O_T")
select c).ToList();
SELECT columns FROM table WHERE
column LIKE '%\%%' ESCAPE '\'来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12641349/viewspace-144778/ ,如需转载,请注明出处,否则将追究法律责任。