How to: Navigate Relationships with the Navigate Operator

 

This topic shows how to execute a command against a conceptual model by using an EntityCommand object, and how to retrieve the RefType results by using an EntityDataReader.

To run the code in this example

  1. Add the AdventureWorks Sales Model to your project and configure your project to use the Entity Framework. For more information, see How to: Use the Entity Data Model Wizard.

  2. In the code page for your application, add the following using statements (Imports in Visual Basic):

    [!CODE [DP EntityServices Concepts#Namespaces](../CodeSnippet/VS_Snippets_Data/dp entityservices concepts#namespaces)]

The following example shows how to navigate relationships in Entity SQL by using the NAVIGATE operator. The Navigate operator takes the following parameters: an instance of an entity, the relationship type, the end of the relationship, and the beginning of the relationship. Optionally, you can pass only an instance of an entity and the relationship type to the Navigate operator.

[!CODE [DP EntityServices Concepts#NavigateWithNavOperatorWithEntityCommand](../CodeSnippet/VS_Snippets_Data/dp entityservices concepts#navigatewithnavoperatorwithentitycommand)]

EntityClient Provider for the Entity Framework
Entity SQL Language

Show: