Hi all! I use a custom web part in Kentico 11. There is a need to get a random document. The variant ".OrderBy (Guid.NewGuid ())" from the page https://devnet.kentico.com/questions/how-to-choose-and-show-a-random-document-on-the-website does not work . Orderby is expecting a string. Tell me there are other options for obtaining a random document in one request? I receive all documents DocumentHelper.GetDocuments()
In your document query, use SQL syntax vs C# syntax.
The NEWID() function generates a unique GUID when called in T-SQL.
Also be sure to set caching to 0 minutes on that document query so it doesn't cache that order by clause.
.OrderBy("NEWID()") it works. thank
Please, sign in to be able to submit a new answer.