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();
}
And it is showing the following error on the code line List<SearchInput> posts = queryable.ToList();
{"Cross partition query is required but disabled. Please set x-ms-documentdb-query-enablecrosspartition to true, specify x-ms-documentdb-partitionkey, or revise your query to avoid this exception.\r\nActivityId: xxxxxx-xxxx-xxx-xxx-xxxxxxx"}
Please help me on it...
C# is a programming language, . NET is a blanket term that tends to cover both the . NET Framework (an application framework library) and the Common Language Runtime which is the runtime in which . NET assemblies are run.
C# (pronounced "See Sharp") is a modern, object-oriented, and type-safe programming language. C# enables developers to build many types of secure and robust applications that run in . NET. C# has its roots in the C family of languages and will be immediately familiar to C, C++, Java, and JavaScript programmers.
. NET was fully written in C and C++ because the base was in assembly language.
NET framework. . NET not only has C#, but through it, you can work with VB, F#, etc.
You should use CreateDocumentQuery
method with FeedOptions
object as a parameter, this class has a property for x-ms-documentdb-query-enablecrosspartition
called EnableCrossPartitionQuery
.
Please follow links https://msdn.microsoft.com/library/en-us/Dn850285.aspx For REST https://learn.microsoft.com/en-us/rest/api/documentdb/querying-documentdb-resources-using-the-rest-api
you should have
var option = new FeedOptions { EnableCrossPartitionQuery = true };
IQueryable<SearchInput> queryable = client.CreateDocumentQuery<SearchInput>
(UriFactory.CreateDocumentCollectionUri(DocumentDBName,
DocumentDBCollectionName), option ) .Where(x => x.Receiver == "8907180");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With