An Azure NoSQL database service for app development.
Select random items from container
Bubba Jones
221
Reputation points
I would like to select some documents from one of my containers. The code below compiles but fails on runtime - the Guid.NewGuid() part it used to work on EF core.
FeedIterator<ForumPost> randomForumPosts =
container.GetItemLinqQueryable<ForumPost>().OrderBy(a => Guid.NewGuid()).Take(5).ToFeedIterator<ForumPost>();
After doing some reading I found that there is no intrinsic way of performing a random selection in cosmos. However those posts were pretty dated. Is there a workaround for this or has there been any update since?
Azure Cosmos DB
Azure Cosmos DB
Sign in to answer