问题描述
我编写了以下代码以从DocumentDB中获取记录
I have written the following code to fetch a record from the DocumentDB
private static void QueryDocuments1(DocumentClient client)
{
IQueryable<SearchInput> queryable =
client.CreateDocumentQuery<SearchInput>(UriFactory.CreateDocumentCollectionUri(DocumentDBName, DocumentDBCollectionName))
.Where(x => x.Receiver == "8907180");
List<SearchInput> posts = queryable.ToList();
}
它在代码行List<SearchInput> posts = queryable.ToList();
请帮助我...
推荐答案
您应该将CreateDocumentQuery
方法与FeedOptions
对象作为参数一起使用,此类具有x-ms-documentdb-query-enablecrosspartition
的称为EnableCrossPartitionQuery
的属性.
You should use CreateDocumentQuery
method with FeedOptions
object as a parameter, this class has a property for x-ms-documentdb-query-enablecrosspartition
called EnableCrossPartitionQuery
.
请点击链接 https://msdn.microsoft.com/library/en -us/Dn850285.aspx 对于REST https://docs.microsoft.com/en-us/rest/api/documentdb/querying-documentdb-resources-using-the-rest-api
Please follow links https://msdn.microsoft.com/library/en-us/Dn850285.aspx For REST https://docs.microsoft.com/en-us/rest/api/documentdb/querying-documentdb-resources-using-the-rest-api
您应该拥有
var option = new FeedOptions { EnableCrossPartitionQuery = true };
IQueryable<SearchInput> queryable = client.CreateDocumentQuery<SearchInput>
(UriFactory.CreateDocumentCollectionUri(DocumentDBName,
DocumentDBCollectionName), option ) .Where(x => x.Receiver == "8907180");
这篇关于.NET-C#-需要跨分区查询,但禁用了DocumentDB数据访问的麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!