# Entity SQL Reference

**.NET Framework 3.5**

This section contains Entity SQL reference topics. In this topic, Entity SQL operators are summarized and grouped by category.

# Arithmetic Operators

Arithmetic operators perform mathematical operations on two expressions of one or more numeric data types. The following table lists the Entity SQL arithmetic operators.

Operator | Use |
---|---|

Addition. | |

Division. | |

Returns the remainder of a division. | |

Multiplication. | |

Negation. | |

Subtraction. |

# Canonical Functions

Canonical functions are supported by all data providers, and can be used by all querying technologies. The following table lists the canonical functions.

Function | Type |
---|---|

Discusses aggregate Entity SQL canonical functions. | |

Discusses math Entity SQL canonical functions. | |

Discusses string Entity SQL canonical functions. | |

Discusses date and time Entity SQL canonical functions. | |

Discusses bitwise Entity SQL canonical functions. | |

Discusses functions not classified as bitwise, date/time, string, math, or aggregate. |

# Comparison Operators

Comparison operators are defined for the following types: **Byte**, **Int16**, **Int32**, **Int64**, **Double**, **Single**, **Decimal**, **String**, **DateTime**, **Date**, **Time**, **DateTimeOffset**. Implicit type promotion occurs for the operands before the comparison operator is applied. Comparison operators always yield Boolean values. When at least one of the operands is **null**, the result is **null**.

Equality and inequality are defined for any object type that has identity, such as the **Boolean** type. Non-primitive objects with identity are considered equal if they share the same identity. The following table lists the Entity SQL comparison operators.

Operator | Description |
---|---|

Compares the equality of two expressions. | |

Compares two expressions to determine whether the left expression has a value greater than the right expression. | |

Compares two expressions to determine whether the left expression has a value greater than or equal to the right expression. | |

Determines if a query expression is null. | |

Compares two expressions to determine whether the left expression has a value less than the right expression. | |

Compares two expressions to determine whether the left expression has a value less than or equal to the right expression. | |

Determines whether an expression results in a value in a specified range. | |

Compares two expressions to determine whether the left expression is not equal to the right expression. | |

Compares two expressions to determine whether the left expression is not equal to the right expression. | |

Determines whether a specific character string matches a specified pattern. |

# Logical and Case Expression Operators

Logical operators test for the truth of a condition. The CASE expression evaluates a set of Boolean expressions to determine the result. The following table lists the logical and CASE expression operators.

Operator | Description |
---|---|

Logical AND. | |

Logical NOT. | |

Logical OR. | |

Evaluates a set of Boolean expressions to determine the result. | |

Imposes conditions on the execution of an Entity SQL statement. | |

The result of a WHEN clause when it evaluates to true. | |

Evaluates one or more Boolean expressions. |

# Query Operators

Query operators are used to define query expressions that return entity data. The following table lists query operators.

Operator | Use |
---|---|

Specifies the collection used in SELECT statements. | |

Specifies groups into which objects returned by a query (SELECT) expression are to be placed. | |

Specifies a search condition for a group or an aggregate. | |

Used with the ORDER BY clause to performed physical paging. | |

Specifies the sort order used on objects returned in a SELECT statement. | |

Specifies the elements in the projection returned by a query. | |

Used with the ORDER BY clause to performed physical paging. | |

Specifies that only the first set of rows will be returned from the query result. | |

Conditionally filters data returned by a query. |

# Reference Operators

A reference is a logical pointer (foreign key) to a specific entity in a specific entity set. Entity SQL supports the following operators to construct, deconstruct and navigate through references.

Operator | Use |
---|---|

Creates references to an entity in an entity set. | |

Dereferences a reference value and produces the result of that dereference. | |

Extracts the key of a reference or of an entity expression. | |

Allows you to navigate over the relationship from one entity type to another | |

Returns a reference to an entity instance. |

# Set Operators

Entity SQL provides various powerful set operations. This includes set operators similar to those in Transact-SQL such as UNION, INTERSECT, EXCEPT, and EXISTS. Entity SQL also supports operators for duplicate elimination (SET), membership testing (IN), and joins (JOIN). The following table lists the Entity SQL set operators.

Operator | Use |
---|---|

Extracts an element from a multivalued collection. | |

Returns a collection of any distinct values from the query expression to the left of the EXCEPT operand that are not also returned from the query expression to the right of the EXCEPT operand. | |

Determines if a collection is empty. | |

Converts a collection of collections into a flattened collection. | |

Determines whether a value matches any value in a collection. | |

Returns a collection of any distinct values that are returned by both the query expressions on the left and right sides of the INTERSECT operand. | |

Determines whether two collections have common elements. | |

Used to convert a collection of objects into a set by yielding a new collection with all duplicate elements removed. | |

Combines the results of two or more queries into a single collection. |

# Type Operators

Entity SQL provides operations that allow the type of an expression (value) to be constructed, queried and manipulated. The following table lists operators used to work with types.

Operator | Use |
---|---|

Converts an expression of one data type to another. | |

Determines whether the type of an expression is of the specified type or one of its subtypes. | |

Returns a collection of objects from a query expression that is of a specific type. | |

Used to create instances of entity types or complex types. | |

Creates an instance of a multiset from a list of values. | |

Constructs anonymous, structurally typed records from one or more values. | |

Treats an object of a particular base type as an object of the specified derived type. |

# Other Operators

The following table lists other Entity SQL operators.

Operator | Use |
---|---|

Used to concatenate strings in Entity SQL. | |

Used to access the value of a property or field of an instance of structural EDM type. | |

Include Entity SQL comments. |