Random rand = new Random();
int toSkip = rand.Next(0, db.Post.Count());
ViewBag.RandomArticle = db.Post.Take(1).OrderBy(o => o.Id).Skip(toSkip).First();
I Have an Entity called "Post" so I get a random record in the database with this query.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.