Where is the LINQ to SQL statement (1)

Source: Internet
Author: User

    • 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 =  from inch db. Customers  where= =  "London"  select C;  

Again: Filter employees who are employed after 1994 years or later:

var =  from inch db. Employees  where>=DateTime(199411) Select e;  

2. Relationship Condition form:

Filter products with inventory levels below the order point level but not broken:

var =  from inch db.  Products where<=&&  ! p.discontinued  select p;  

Filter out products with UnitPrice greater than 10 or discontinued:

var =  from inch db. Products where>| | 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.

vardb. Products. Where (p=> 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.

= db. Shippers.first ();

Element: Select a single customer with CustomerID as "Bonap"

= = == "Bonap");

Condition: Select an order with freight greater than 10.00:

Order = = > 00M);

Where is the LINQ to SQL statement (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.