实体 SQL 引用Entity SQL reference

本部分包含实体 SQL 参考文章。This section contains Entity SQL reference articles. 本文按类别汇总并分组实体 SQL 运算符。This article summarizes and groups the Entity SQL operators by category.

算术运算符Arithmetic operators

算术运算符对两个表达式执行数学运算,这两个表达式可以是一个或多个数值数据类型。Arithmetic operators perform mathematical operations on two expressions of one or more numeric data types. 下表列出了实体 SQL 算术运算符:The following table lists the Entity SQL arithmetic operators:

运算符Operator 使用Use
+(加)+ (Add) 加。Addition.
/(除)/ (Divide) 除。Division.
%(取模)% (Modulo) 返回除法运算的余数。Returns the remainder of a division.
*(乘)* (Multiply) 乘。Multiplication.
-(负)- (Negative) 求反。Negation.
-(减)- (Subtract) 减。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
聚合 Entity SQL 规范函数Aggregate Entity SQL Canonical Functions 讨论聚合实体 SQL 规范函数。Discusses aggregate Entity SQL canonical functions.
数学规范函数Math Canonical Functions 讨论数学实体 SQL 规范函数。Discusses math Entity SQL canonical functions.
字符串规范函数String Canonical Functions 讨论字符串实体 SQL 规范函数。Discusses string Entity SQL canonical functions.
日期和时间规范函数Date and Time Canonical Functions 讨论实体 SQL 规范函数的日期和时间。Discusses date and time Entity SQL canonical functions.
按位规范函数Bitwise Canonical Functions 讨论按位实体 SQL 规范函数。Discusses bitwise Entity SQL canonical functions.
其他规范函数Other Canonical Functions 讨论未分类为按位、日期/时间、字符串、数字或聚合函数的函数。Discusses functions not classified as bitwise, date/time, string, math, or aggregate.

比较运算符Comparison operators

比较运算符适用于下列类型:ByteInt16Int32Int64DoubleSingleDecimalStringDateTimeDateTimeDateTimeOffsetComparison 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. 如果操作数中至少有一个 null,则结果为 nullWhen at least one of the operands is null, the result is null.

相等和不相等适用于有标识的所有对象类型,如 Boolean 类型。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. 下表列出了实体 SQL 比较运算符:The following table lists the Entity SQL comparison operators:

运算符Operator 说明Description
=(等于)= (Equals) 比较两个表达式是否相等。Compares the equality of two expressions.
>(大于)> (Greater Than) 比较两个表达式以确定左侧表达式的值是否大于右侧表达式的值。Compares two expressions to determine whether the left expression has a value greater than the right expression.
>=(大于或等于)>= (Greater Than or Equal To) 比较两个表达式以确定左侧表达式的值是否大于或等于右侧表达式的值。Compares two expressions to determine whether the left expression has a value greater than or equal to the right expression.
不 [ 为 ] NULLIS [NOT] NULL 确定查询表达式是否为 null。Determines if a query expression is null.
<(小于)< (Less Than) 比较两个表达式以确定左侧表达式的值是否小于右侧表达式的值。Compares two expressions to determine whether the left expression has a value less than the right expression.
<=(小于或等于)<= (Less Than or Equal To) 比较两个表达式以确定左侧表达式的值是否小于或等于右侧表达式的值。Compares two expressions to determine whether the left expression has a value less than or equal to the right expression.
[不 ] 介于[NOT] BETWEEN 确定表达式的结果值是否在指定范围内。Determines whether an expression results in a value in a specified range.
!= (不等于) != (Not Equal To) 比较两个表达式以确定左侧表达式是否不等于右侧表达式。Compares two expressions to determine whether the left expression isn't equal to the right expression.
[不 ] 类似于[NOT] LIKE 确定特定字符串是否与指定模式相匹配。Determines whether a specific character string matches a specified pattern.

逻辑和 case 表达式运算符Logical and case expression operators

逻辑运算符测试条件的真实性。Logical operators test for the truth of a condition. CASE 表达式计算一组布尔表达式的值以确定结果。The CASE expression evaluates a set of Boolean expressions to determine the result. 下表列出了逻辑 and CASE 表达式运算符:The following table lists the logical and CASE expression operators:

运算符Operator 说明Description
(逻辑与)&& && (Logical AND) 逻辑 AND。Logical AND.
! (逻辑非) ! (Logical NOT) 逻辑非。Logical NOT.
|| (逻辑或) || (Logical OR) 逻辑 OR。Logical OR.
CASECASE 求出一组布尔表达式的值以确定结果。Evaluates a set of Boolean expressions to determine the result.
THENTHEN when 子句的计算结果为 true 时的结果。The result of a WHEN clause when it evaluates to true.

查询运算符Query operators

查询运算符用于定义返回实体数据的查询表达式。Query operators are used to define query expressions that return entity data. 下表列出了查询运算符:The following table lists query operators:

运算符Operator 使用Use
FROMFROM 指定在 SELECT 语句中使用的集合。Specifies the collection that is used in SELECT statements.
GROUP BYGROUP BY 指定由查询返回的对象 (选择 要放置) 表达式的组。Specifies groups into which objects that are returned by a query (SELECT) expression are to be placed.
GroupPartitionGroupPartition 返回从聚合与之相关的组分区提取的参数值集合。Returns a collection of argument values, projected off the group partition to which the aggregate is related.
HAVINGHAVING 指定组或聚合的搜索条件。Specifies a search condition for a group or an aggregate.
上限LIMIT ORDER BY 子句一起使用,以执行物理分页。Used with the ORDER BY clause to performed physical paging.
ORDER BYORDER BY 指定在 SELECT 语句中返回的对象上使用的排序顺序。Specifies the sort order that is used on objects returned in a SELECT statement.
SELECTSELECT 指定投影中由查询返回的元素。Specifies the elements in the projection that are returned by a query.
SKIP ORDER BY 子句一起使用,以执行物理分页。Used with the ORDER BY clause to performed physical paging.
TOPTOP 指定查询结果中将只返回第一组行。Specifies that only the first set of rows will be returned from the query result.
WHEREWHERE 按条件筛选由查询返回的数据。Conditionally filters data that is returned by a query.

Reference 运算符Reference operators

引用是指向特定实体集中的特定实体的逻辑指针(外键)。A reference is a logical pointer (foreign key) to a specific entity in a specific entity set. 实体 SQL 支持以下运算符来构造、析构和导航引用:Entity SQL supports the following operators to construct, deconstruct, and navigate through references:

运算符Operator 使用Use
CREATEREFCREATEREF 创建对实体集中的实体的引用。Creates references to an entity in an entity set.
DEREFDEREF 取消引用一个引用值,并生成该取消引用的结果。Dereferences a reference value and produces the result of that dereference.
KEYKEY 提取引用或实体表达式的键。Extracts the key of a reference or of an entity expression.
引导NAVIGATE 使您可以从一个实体类型到另一个实体类型对关系进行导航Allows you to navigate over the relationship from one entity type to another
REFREF 返回对实体实例的引用。Returns a reference to an entity instance.

集合运算符Set operators

实体 SQL 提供各种功能强大的设置操作。Entity SQL provides various powerful set operations. 这包括类似于 Transact-sql 运算符(如 UNION、INTERSECT、EXCEPT 和 EXISTS)的集运算符。This includes set operators similar to Transact-SQL operators such as UNION, INTERSECT, EXCEPT, and EXISTS. 实体 SQL 还支持重复消除 (集) 、) 中的成员资格测试 (以及联接 (联接) 的运算符。Entity SQL also supports operators for duplicate elimination (SET), membership testing (IN), and joins (JOIN). 下表列出了实体 SQL 集运算符:The following table lists the Entity SQL set operators:

运算符Operator 使用Use
ANYELEMENTANYELEMENT 从多值集合中提取元素。Extracts an element from a multivalued collection.
EXCEPTEXCEPT 返回一个集合,该集合中的所有非重复值都是从除除运算符右侧的查询表达式返回的查询表达式中的任何非重复值。Returns a collection of any distinct values from the query expression to the left of the EXCEPT operand that aren't also returned from the query expression to the right of the EXCEPT operand.
[不 ] 存在[NOT] EXISTS 确定集合是否为空。Determines if a collection is empty.
FLATTEN 将一个由多个集合组成的集合转换为一个平展集合。Converts a collection of collections into a flattened collection.
[不 ] 在[NOT] IN 确定某个值是否与某个集合中的任何值匹配。Determines whether a value matches any value in a collection.
INTERSECTINTERSECT 返回 INTERSECT 操作数左右两边的两个查询表达式均返回的所有非重复值的集合。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.
OVERLAPSOVERLAPS 确定两个集合是否具有公共元素。Determines whether two collections have common elements.
SETSET 用于通过生成一个新集合(其中移除了所有重复元素)将对象集合转换为一个集。Used to convert a collection of objects into a set by yielding a new collection with all duplicate elements removed.
UNIONUNION 将两个或更多查询的结果组合成单个集合。Combines the results of two or more queries into a single collection.

类型运算符Type operators

实体 SQL 提供了允许构造、查询和操作表达式 (值) 类型的操作。Entity SQL provides operations that allow the type of an expression (value) to be constructed, queried, and manipulated. 下表列出了用于处理类型的运算符:The following table lists operators that are used to work with types:

运算符Operator 使用Use
CASTCAST 将一种数据类型的表达式转换为另一种数据类型的表达式。Converts an expression of one data type to another.
集合COLLECTION 函数 操作中用于声明实体类型或复杂类型的集合。Used in a FUNCTION operation to declare a collection of entity types or complex types.
[不是 ]IS [NOT] OF 确定表达式的类型是否为指定类型或指定类型的某个子类型。Determines whether the type of an expression is of the specified type or one of its subtypes.
OFTYPEOFTYPE 从查询表达式返回特定类型的对象集合。Returns a collection of objects from a query expression that is of a specific type.
命名类型构造函数Named Type Constructor 用于创建实体类型或复杂类型的实例。Used to create instances of entity types or complex types.
MULTISETMULTISET 根据值列表创建多集的实例。Creates an instance of a multiset from a list of values.
ROWROW 从一个或多个值构造结构上类型化的匿名记录。Constructs anonymous, structurally typed records from one or more values.
TREATTREAT 将特定基类型的对象视为指定派生类型的对象。Treats an object of a particular base type as an object of the specified derived type.

其他运算符Other operators

下表列出了其他实体 SQL 运算符:The following table lists other Entity SQL operators:

运算符Operator 使用Use
+(字符串串联)+ (String Concatenation) 用于在实体 SQL 中串联字符串。Used to concatenate strings in Entity SQL.
. (成员访问) . (Member Access) 用于访问结构化概念模型类型实例的属性或字段的值。Used to access the value of a property or field of an instance of structural conceptual model type.
--(注释)-- (Comment) 包括实体 SQL 注释。Include Entity SQL comments.
FUNCTIONFUNCTION 定义可在 Entity SQL 查询中执行的内联函数。Defines an inline function that can be executed in an Entity SQL query.

请参阅See also