To get the 10 most recent reviews from the system, your query needs two important LINQ constructs:
first, it needs an Order By (orderby in C#) clause to order the list in descending order. It
then needs the Take method to take the first 10 reviews from that result set:
Code:
using (PlanetWroxEntities myEntities = new PlanetWroxEntities())
{
var recentReviews = (from myReview in myEntities.Reviews
orderby myReview.CreateDateTime descending
select new { myReview.Title, myReview.Genre.Name }).Take(10);
GridView1.DataSource = recentReviews;
GridView1.DataBind();
}
What's the markup for this exercise. I'm using a repeater but I cannot get it to work to take the first 10 reviews?