Data Access has been discontinued. Please refer to this page for more information.

How to: Navigate Relationships Using Navigation Properties

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

This topic shows how to navigate relationships through navigation properties (references). The example gets all the orders which ShipCity is "Lyon". The Order.Customer navigation property is used to get the Customer object.

To run the code in this example, you need to create a new Telerik Data Access Domain Model based on the Northwind database.

The following code is the LINQ example.

using ( EntitiesModel dbContext = new EntitiesModel() )
   var query = from order in dbContext.Orders
               where order.ShipCity == "Lyon"
               select new
   foreach ( var item in query)
       Console.WriteLine( "OrderId: {0}, CustomerId: {1}, CustomerCountry: {2}", 
           item.OrderID, item.Customer.CustomerID, item.Customer.Country );
Using dbContext As New EntitiesModel()
 Dim query = From order In dbContext.Orders
    Where order.ShipCity = "Lyon"
    Select New With {Key order.OrderID, Key order.Customer}
 For Each item In query
  Console.WriteLine("OrderId: {0}, CustomerId: {1}, CustomerCountry: {2}", _
      item.OrderID, item.Customer.CustomerID, item.Customer.Country)
 Next item
End Using

See Also