您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

关于 Azure 数字孪生的查询语言About the query language for Azure Digital Twins

回忆一下,Azure 数字孪生中心是从数字孪生关系构建的双子图形Recall that the center of Azure Digital Twins is the twin graph, constructed from digital twins and relationships. 可以查询此关系图以获取有关它所包含的数字孪生和关系的信息。This graph can be queried to get information about the digital twins and relationships it contains. 这些查询使用类似于 SQL 的自定义查询语言编写,称为Azure 数字孪生查询语言These queries are written in a custom SQL-like query language, referred to as the Azure Digital Twins query language.

若要从客户端应用将查询提交到服务,请使用 Azure 数字孪生查询 APITo submit a query to the service from a client app, you will use the Azure Digital Twins Query API. 这使开发人员可以编写查询并应用筛选器来查找孪生中的数字集,以及有关 Azure 数字孪生方案的其他信息。This lets developers write queries and apply filters to find sets of digital twins in the twin graph, and other information about the Azure Digital Twins scenario.

查询语言功能Query language features

Azure 数字孪生针对大容量图形提供丰富的查询功能。Azure Digital Twins provides extensive query capabilities against the twin graph. 使用类似于 SQL 的语法,使用类似于 SQL 的语法(类似于IoT 中心查询语言,具有许多可比较功能)对查询进行了说明。Queries are described using SQL-like syntax, in a query language similar to the IoT Hub query language with many comparable features.

备注

所有 Azure 数字孪生查询操作都区分大小写。All Azure Digital Twins query operations are case-sensitive.

下面是 Azure 数字孪生查询语言中可用的操作。Here are the operations available in Azure Digital Twins query language.

获取数字孪生,按 .。。Get digital twins by their...

  • 使用 IS_OF_MODEL operator) (模型model (using IS_OF_MODEL operator)
  • 属性 (包括标记属性) properties (including tag properties)
  • 接口interfaces
  • 关系relationships
    • 关系的属性properties of the relationships

可以通过以下操作进一步增强查询:You can further enhance your queries with the following operations:

  • (查询) 的多个关系类型上获取孪生 JOINGet twins over multiple relationship types (JOIN queries).
    • JOIN对于公共预览) ,允许 (一级的数量存在限制。There are limitations on the number of JOINs allowed (one level for public preview).
  • 仅选择最上面的查询结果 (Select TOP 运算符) Select only the top query results (Select TOP operator)
  • 使用标量函数: IS_BOOLIS_DEFINEDIS_NULLIS_NUMBERIS_OBJECTIS_PRIMITIVE IS_STRING STARTSWITH ENDSWITH 、、和。Use scalar functions: IS_BOOL, IS_DEFINED, IS_NULL, IS_NUMBER, IS_OBJECT, IS_PRIMITIVE, IS_STRING, STARTSWITH, ENDSWITH.
  • 使用查询比较运算符: IN / NIN=!=<><=>=Use query comparison operators: IN/NIN, =, !=, <, >, <=, >=.
  • 使用任意组合 (ANDORNOT 运算符) IS_OF_MODEL 、标量函数和比较运算符。Use any combination (AND, OR, NOT operator) of IS_OF_MODEL, scalar functions, and comparison operators.
  • 使用延续:查询对象的实例化页面大小最多为 100) (。Use continuation: The query object is instantiated with a page size (up to 100). 可以通过在后续对 API 的调用中提供继续标记,一次检索一页中的数字孪生。You can retrieve the digital twins one page at a time by providing the continuation token in subsequent calls to the API.

后续步骤Next steps

了解如何编写查询,以及如何在操作方法:查询双子图中查看客户端代码示例。Learn how to write queries and see client code examples in How-to: Query the twin graph.