Series Article Navigation:
Where is the LINQ to SQL statement (1)
Select/distinct of LINQ to SQL statements (2)
Count/sum/min/max/avg of LINQ to SQL statements (3)
Join of LINQ to SQL statements (4)
Order by of the LINQ to SQL statement (5)
Group by/having for LINQ to SQL statements (6)
Exists/in/any/all/contains of LINQ to SQL statements (7)
Concat/union/intersect/except of LINQ to SQL statements (8)
LINQ to SQL statements (9) Top/bottom and paging and sqlmethods
Insert of LINQ to SQL statement (10)
Update for LINQ to SQL statements (11)
Delete and use attach of LINQ to SQL statements (12)
Open concurrency control and transactions for LINQ to SQL statements (13)
Null semantics and datetime for LINQ to SQL statements (14)
String for LINQ to SQL statement (15)
Object identifiers for LINQ to SQL statements (16)
Object loading for LINQ to SQL statements (17)
The conversion of an operator to a LINQ to SQL statement (18)
LINQ to SQL statement (19) ADO. LINQ to SQL
The stored procedure for LINQ to SQL statements (20)
User-defined functions for LINQ to SQL statements (21)
DataContext of LINQ to SQL statements (22)
Dynamic query of LINQ to SQL statements (23)
View of LINQ to SQL statements (24)
Inheritance of LINQ to SQL statements (25)
Introduction to LINQ
Adsfsaf
where operation
Application Scenario: filter, Query and other functions.
Description: similar to where in the SQL command, it is scoped to filter, and the judging condition is the clause that is followed by it.
The where operation consists of 3 forms, namely the simple form, the relationship condition form, and the first () Form. The following examples are used for example:
1. Simple form:
Example: use where to filter customers in London
var q = from C in db. Customers where c.city = = "London" select C;
Again: Filter employees who are employed after 1994 years or later:
var q = from e in db. Employees where e.hiredate >= new DateTime (1994, 1, 1) select E;
2. Relationship Condition form:
Filter products with inventory levels below the order point level but not broken:
var q = from p in db. Products where P.unitsinstock <= p.reorderlevel &&!p.discontinued select p;
Filter out products with UnitPrice greater than 10 or discontinued:
var q = from p in db. Products where P.unitprice > 10m | | p.discontinued SELECT p;
The following example calls a two-time where to filter out products that have unitprice greater than 10 and that have been discontinued.
var q = db. Products.where (P=>p.unitprice > 10m). Where (p=>p.discontinued);
3.First () Form:
Returns an element in the collection, with the essence of adding top (1) to the SQL statement.
Simple usage: Select the first shipper in a table.
Shipper Shipper = db. Shippers.first ();
Element: Select a single customer with CustomerID as "Bonap"
Customer cust = db. Customers.first (c = C.customerid = = "Bonap");
Condition: Select an order with freight greater than 10.00:
Order ord = db. Orders.first (o = o.freight > 10.00M);
http://kb.cnblogs.com/page/42465/