I would like to know if there is a way to select randomly documents in CosmosDB (Microsoft Azure).
Here is my code, I do not know what to add before "Take(20)":
public List<LeafBook> BooksList { get; private set; }
public async Task<List<LeafBook>> GetBookAsync()
{
try
{
// The query excludes completed TodoItems
var query = client.CreateDocumentQuery<LeafBook>(collectionLink, new FeedOptions { MaxItemCount = -1 })
.Take(20)
.AsDocumentQuery();
BooksList = new List<LeafBook>();
while (query.HasMoreResults)
{
BooksList.AddRange(await query.ExecuteNextAsync<LeafBook>());
}
}
catch (Exception e)
{
Console.Error.WriteLine(@"ERROR {0}", e.Message);
return null;
}
return BooksList;
}