Reputation: 3
I have database. Actually,i am doing for it display 10 image newest from my database but i want to display random 10 image from database.How can i do it?
public ActionResult Details(int id)
{
var products = db.TblProductImages.Include(t => t.TblProduct);
ViewData["viewcategory"] = (from p in products orderby p.ProductID descending select p).Take(10).ToList();
if (image == null)
{
return HttpNotFound();
}
return View(image);
}
Upvotes: 0
Views: 1510
Reputation: 1770
Do this:
(from p in products orderby Guid.NewGuid() select p).Take(10).ToList()
Upvotes: 4