Hi there,
There are a couple of different ways to do it. One solution is to use Include (see page 505) to include the Gene and then build a new anonymous object (see page 512) to select the properties from Review you need and also include the Genre.Name, like this:
Code:
var authorizedReviews = from review in myEntities.Reviews.Include("Genre")
where review.Authorized == true
orderby review.CreateDateTime descending
select new
{
review.Id,
review.Title,
review.Summary,
review.Body,
review.GenreId,
review.Genre.Name,
review.Authorized,
review.CreateDateTime,
review.UpdateDateTime
};
GridView1.DataSource = authorizedReviews;
GridView1.DataBind();
This selects all properties from the Review but also includes review.Genre.Name which is then rendered in the GridView in the Name column. If you want to rename it, you could do something like this:
GenreName = review.Genre.Name,
Instead of relying on automatically created columns you can also convert the GridView to templates and then bind the genre to Genre.Name instead of GenreId.
Hope this helps,
Imar