Select 属性加上 Azure DocumentDB select 查询中的自链接
Select properties plus selflink in an Azure DocumentDB select query
我使用 c# 来 select 来自 Azure DocumentDB 的文档,代码如下:
var documents = _connection.Client.CreateDocumentQuery<Document>(_collection.DocumentsLink,
"SELECT {'id':s.Id, 'property1':s.property1} AS customDoc FROM Name1 s").ToList();
如何将自链接添加到我正在 select 的 'custom' 文档中?
如果我使用星号,我可以访问自链接,但我不想 select 所有属性。具有所有属性的示例查询:
"SELECT * FROM Name1"
有没有办法 select 某些属性并添加自链接?
是的,您可以添加自己 link 与您选择的其他节点相同。使用您的代码示例,只需添加对 s._self 的引用并为其命名(为了保持一致性,我将其命名为 _self 但您可以随意调用它)。
var documents = _connection.Client.CreateDocumentQuery<Document>(_collection.DocumentsLink,
"SELECT {'id':s.Id, 'property1':s.property1, '_self' : s._self} AS customDoc FROM Name1 s").ToList();
我使用 c# 来 select 来自 Azure DocumentDB 的文档,代码如下:
var documents = _connection.Client.CreateDocumentQuery<Document>(_collection.DocumentsLink,
"SELECT {'id':s.Id, 'property1':s.property1} AS customDoc FROM Name1 s").ToList();
如何将自链接添加到我正在 select 的 'custom' 文档中? 如果我使用星号,我可以访问自链接,但我不想 select 所有属性。具有所有属性的示例查询:
"SELECT * FROM Name1"
有没有办法 select 某些属性并添加自链接?
是的,您可以添加自己 link 与您选择的其他节点相同。使用您的代码示例,只需添加对 s._self 的引用并为其命名(为了保持一致性,我将其命名为 _self 但您可以随意调用它)。
var documents = _connection.Client.CreateDocumentQuery<Document>(_collection.DocumentsLink,
"SELECT {'id':s.Id, 'property1':s.property1, '_self' : s._self} AS customDoc FROM Name1 s").ToList();