Literals

This topic describes Entity SQL support for literals.

Null

The null literal is used to represent the value null for any type. A null literal is compatible with any type.

Boolean

Boolean literals are represented by the keywords true and false

Integer

Integer literals can be of type Int32 or Int64. An Int32 literal is a series of numeric characters. An Int64 literal is series of numeric characters followed by a character L(upper or lower).

Decimal

A fixed-point number (decimal) is a series of numeric characters, a dot (.) and another series of numeric characters followed by an a character M(upper or lower).

Double

A double-precision floating point number is a series of numeric characters, a dot (.) and another series of numeric characters possibly followed by an exponent.

Float

A single-precisions floating point number (or float) is a double-precision floating point number syntax followed by a character F (upper or lower).

String

A string is a series of characters enclosed in quote marks. Quotes can be either both single-quotes (') or both double-quotes (").
'hello' -- non-Unicode character string literal
"x"
'so is THIS'

DateTime

A datetime literal is independent of locale and is composed of a date part and a time part. Both date and time parts are mandatory and there are no default values.

The date part must have the format: YYYY-MM-DD, where YYYY is a four digit year value between 0001 and 9999, MM is the month between 1 and 12 and DD is the day value that is valid for the given month MM.

There can be any number of spaces between the DATETIME symbol and the literal payload, but no new lines or enclosed in #.
DATETIME '2006-12-25 01:01'
#2006-12-25 01:01#

Binary

A binary string literal is a sequence of hexadecimal digits delimited by single quotes following the keyword binary or the shortcut symbol X. Note that as a keyword, binary is case insensitive. Also, zero or more spaces are allowed between the keyword binary and the binary string value.
The shortcut symbol X must be uppercase and cannot have any spaces between the symbol X and the binary string. Hexadecimal characters are also case insensitive. If the literal is composed of an odd number of hexadecimal digits, the literal will be aligned to the next even hexadecimal digit by prefixing the literal with a hexadecimal zero digit. There is no formal limit on the size of the binary string.
There can be no spaces between the X symbol and the string literal payload, and X must be uppercase. There can be any number of spaces between the BINARY symbol and the literal payload, but no new lines.
Binary'00ffaabb'
X'ABCabc'
BINARY    '0f0f0f0F0F0F0F0F0F0F'
X'' –- empty binary string

Guid

A GUID literal represents a globally unique identifier. It is a sequence formed by the keyword GUID followed by hexadecimal digits in the form known as registry format: 8-4-4-4-12 enclosed in single quotes. Hexadecimal digits are case insensitive.
There can be any number of spaces between the GUID symbol and the literal payload, but no new lines.
Guid'1afc7f5c-ffa0-4741-81cf-f12eAAb822bf'
GUID  '1AFC7F5C-FFA0-4741-81CF-F12EAAB822BF'

Last edited Mar 7, 2013 at 12:45 PM by ansiboy, version 2

Comments

No comments yet.