Entity Framework Learning Primary 4--entity SQL

Source: Internet
Author: User

Entity SQL is the SQL class language provided by the Ado.net Entity Framework to support the Entity Data Model (EDM). Entity SQL can be used for object queries and queries executed using the EntityClient provider.

L Key Words

Value keyword

ESQL provides a SELECT value clause to skip implicit row constructs. Only one item can be specified in the SELECT value clause. When you use such a clause, the line wrapper is not constructed on the items in the SELECT clause, and you can generate a collection of the shapes you want, for example: SELECT VALUE it from northwindentities.customers as it

It keywords

It appears in eSQL, and the alias default value of the query object "It" is changed to another string, for example:

"Select VALUE it from Northwindentities.customers as it".

L Note:

Entity SQl queries can contain comments. The comment line starts with a two dash (-).

"Select VALUE it from Northwindentities.customers as it--this a comment"

L Select query

For example:

SELECT VALUE it from northwindentities.customers as it

L Parameters

Arguments are variables defined outside of esql, each with a name and type, a parameter name defined in a query expression, and prefixed with the @ symbol. For example:

Select VALUE C from Northwindentities.customers as C where c.customerid= @customerID

L Polymerization

Enity SQL does not support *, so ESQL does not support count (*), but instead uses count (0), for example:

Select count (0) from Northwindentities.customers

L Paging Skip/limit

You can perform physical paging by using the SKIP and limit child clauses in the ORDER BY clause. To perform physical paging in a certain way, you should use Skip and LIMIT. If you just want to limit the number of rows in the result in an indeterminate way, you should use top. Top and Skip/limit are mutually exclusive.

Using Skip/limit paging, the ESQL code is as follows:

Select value C from northwindentities.customers as C c.customerid Skip 0 limit 10

L Top

The SELECT clause can have an optional top child clause after an optional all/distinct modifier. The top sub clause specifies that only the first set of rows will be returned in the query results. The ESQL code is as follows:

Select top C.customerid from Northwindentities.customers as C-ORDER by C.customerid

L NULL Processing

Null literals are compatible with any type in the Entity SQL type System, and you can use cast for type conversions, such as:

Select cast (C.region as String) from Northwindentities.customers as C order by C.customerid limit 10

Where nvarchar can be string, numeric types can be converted to Int32, and other type conversions are similar. If the conversion cannot be completed, the exception is reported. There are also ways to deal with treat.

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.