This project is read-only.

Simple Identifiers

A simple identifier in Entity SQL is a sequence of alphanumeric and underscore characters. The first character of the identifier must be an alphabetical character (a-z or A-Z).
!!Quoted Identifiers
A quoted identifier is any sequence of characters enclosed in square brackets ([]). Quoted identifiers let you specify identifiers with characters that are not valid in identifiers. All characters between the square brackets become part of the identifier, including all whitespace.
A quoted identifier cannot include the following characters:
  1. Newline.
  2. Carriage returns.
  3. Tabs.
  4. Backspace.
  5. Additional square brackets (that is, square brackets within the square brackets that delineate the identifier).
A quoted-identifier can include Unicode characters.
Quoted identifiers enable you to create property name characters that are not valid in identifiers, as illustrated in the following example:
SELECT c.ContactName AS [Contact Name] FROM customers AS c
You can also use quoted identifiers to specify an identifier that is a reserved keyword of Entity SQL. For example, if the type Email has a property named "From", you can disambiguate it from the reserved keyword FROM by using square brackets, as follows:
SELECT e.[From] FROM emails AS e
You can use a quoted identifier on the right side of a dot (.) operator.
SELECT t FROM ts as t WHERE t.[property] == 2
To use the square bracket in an identifier, add an extra square bracket. In the following example "abc]" is the identifier:
SELECT t from ts as t WHERE t.[abc]]] == 2

Aliasing Rules

We recommend specifying aliases in Entity SQL queries whenever needed, including the following Entity SQL constructs:
  1. Fields of a row constructor.
  2. Items in the FROM clause of a query expression.
  3. Items in the SELECT clause of a query expression.
  4. Items in the GROUP BY clause of a query expression.
Valid Aliases
Valid aliases in Entity SQL are any simple identifier or quoted identifier.

Alias Generation
If no alias is specified in an Entity SQL query expression, Entity SQL tries to generate an alias based on the following simple rules:
  1. If the query expression (for which the alias is unspecified) is a simple or quoted identifier, that identifier is used as the alias. For example, ROW(a, [b]) becomes ROW(a AS a, [b] AS [b]).
  2. If the query expression is a more complex expression, but the last component of that query expression is a simple identifier, then that identifier is used as the alias. For example, ROW(a.a1, b.[b1]) becomes ROW(a.a1 AS a1, b.[b1] AS [b1]).
We recommend that you do not use implicit aliasing if you want to use the alias name later. Anytime aliases (implicit or explicit) conflict or are repeated in the same scope, there will be a compile error. An implicit alias will pass compilation even if there is an explicit or implicit alias of the same name.
Implicit aliases are autogenerated based on user input. For example, the following line of code will generate NAME as an alias for both columns and therefore will conflict.
SELECT product.NAME, person.NAME
The following line of code, which uses explicit aliases, will also fail. However, the failure will be more apparent by reading the code.

Last edited Mar 7, 2013 at 10:34 AM by ansiboy, version 3


No comments yet.