cosmos db get all items code example
Example: cosmos db get all items in container
CosmosClient cosmosClient = new CosmosClient(Uri, PrimaryKey);
Database database = cosmosClient.GetDatabase(DatabaseId);
Container container = database.GetContainer(ContainerId);
string sqlQueryText = "SELECT * FROM c";
QueryDefinition definition = new QueryDefinition(sqlQueryText);
var iterator = container.GetItemQueryIterator<Test>(definition);
while (iterator.HasMoreResults)
{
FeedResponse<Test> result = await iterator.ReadNextAsync();
foreach (var item in result)
{
Console.Writeline(item.property);
}
}