in vnext/code-samples/dotnet/src/cosmosdb-vnext-test/Program.cs [230:248]
private async Task QueryDocumentsByPartitionKeyAsync(Container container, string partitionKey)
{
Console.WriteLine($"Querying documents with partition key: {partitionKey}");
// Query documents using LINQ with a partition key filter
var queryable = container.GetItemLinqQueryable<TestDocument>(
allowSynchronousQueryExecution: true,
requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey(partitionKey) }
);
int count = 0;
foreach (var document in queryable)
{
Console.WriteLine($"Found document: Id={document.Id}, Queryfield={document.Queryfield}, PartitionKey={document.PartitionKey}, City={document.City}");
count++;
}
Console.WriteLine($"Found {count} document(s) with partition key {partitionKey}");
}