News Feeds

No results for 'undefined'
Powered by Algolia
Cosmos DB read a single document without partition key

Author: Thomas Segato

Originally Sourced from:

A container has a function called ReadItemAsync. The problem is I do not have the partition key, but only the id of the document. What is the best approach to get just a single item then?

Do I have to get it from a collection? Like:

var allItemsQuery = VesselContainer.GetItemQueryIterator<CoachVessel>("SELECT * FROM c where");

var q = VesselContainer.GetItemLinqQueryable<CoachVessel>();
var iterator = q.ToFeedIterator();

var result = new List<CoachVessel>();
while (iterator.HasMoreResults)
    foreach (var item in await iterator.ReadNextAsync())