There's 2 options. One is to simply include that related object in your query using the Include method (see the Navigating Entity Associations section in Chapter 29 of the book), and then use dot notation in your report to get to the property or properties you need. Alternativately, you can create a collection of anonymous objects, including the related field in the objects, like so:
var query =
from order in context.Orders
select new
{
OrderId = order.OrderID,
OrderDate = order.Date,
CustomerName = order.Customers.CustomerName
};
__________________
Chris Anderson
Co-author
|