Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在azure db中获取文档集合?_C#_Azure - Fatal编程技术网

C# 在azure db中获取文档集合?

C# 在azure db中获取文档集合?,c#,azure,C#,Azure,在云功能中使用Azure DB,我有以下几点: var client = new DocumentClient(new Uri(endPoint), primaryKey); var collUrl = UriFactory.CreateDocumentCollectionUri("id", "course"); var doc = (await client.ReadDocumentCollectionAsync(collUrl)).Reso

在云功能中使用Azure DB,我有以下几点:

 var client = new DocumentClient(new Uri(endPoint), primaryKey);
            var collUrl = UriFactory.CreateDocumentCollectionUri("id", "course");

            var doc = (await client.ReadDocumentCollectionAsync(collUrl)).Resource;
doc是一个DocumentCollection,但它看起来没有任何方法访问枚举器或其他东西来查看内容,所以我可能在错误的位置

doc是一个文档集合

由于您认识到文档是文档集合,更多详细信息请参阅 方法用于作为异步操作从Azure Cosmos DB服务读取DocumentCollection

但是看起来没有任何方法可以访问枚举器或其他东西来查看内容,所以我可能在错误的位置

如果您想列出集合中的文档,我们可以使用方法来完成。我们还可以从


据我所知,集合本身没有迭代器。但是,您可以对集合创建如下查询:

var docs = client.CreateDocumentQuery(collUrl);
foreach (var document in docs)
{
    // Do stuff with your document
}

请注意,此时CreateDocumentQuery有很多重载。

如果它是分区集合,还必须指定分区键或启用跨分区查询。
var docs = client.CreateDocumentQuery(collUrl);
foreach (var document in docs)
{
    // Do stuff with your document
}