Telerik OpenAccess ORM

Telerik OpenAccess ORM Send comments on this topic.
How to: Navigate Relationships Using Navigation Properties
See Also
Programmer's Guide > Feature Reference > API > LINQ Guide > How to: Navigate Relationships Using Navigation Properties

Glossary Item Box

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 OpenAccess Domain Model based on the Northwind database.

The following code is the LINQ example.

C# Copy Code
using ( EntitiesModel dbContext = new EntitiesModel() )
{
   var query = from order
in dbContext.Orders
               where order.ShipCity ==
"Lyon"
               
select new
               {
                   
order.OrderID,
                   order.Customer
               };
   
foreach ( var item in query)
   {
       Console.WriteLine(
"OrderId: {0}, CustomerId: {1}, CustomerCountry: {2}", item.OrderID, item.Customer.CustomerID, item.Customer.Country );
   }
}
VB.NET Copy Code
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