【问题标题】:return id of newly created document in DocumentDB within .NET Core返回 .NET Core 中 DocumentDB 中新创建文档的 id
【发布时间】:2018-04-21 09:38:01
【问题描述】:

我正在使用以下内容创建 DocumentDB 文档,如何修改它以返回创建的文档的 guid id?

            _logger.LogInformation("creating document");
            Uri uri = UriFactory.CreateDocumentCollectionUri(DatabaseId, CollectionId);
            await client.CreateDocumentAsync(uri, doc);

【问题讨论】:

    标签: c# asp.net-core-webapi document-database


    【解决方案1】:

    保存后直接从文档中读取id值:

     await client.CreateDocumentAsync(uri, doc);
     _logger.LogInformation($"created document {doc.Id}");
    

    【讨论】:

      猜你喜欢
      • 2020-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多