C# 在azure db中获取文档集合?
在云功能中使用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
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
}