How to: Use Query Paths to Shape Results

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

This topic provides an example of how to specify a query path that defines which related objects are returned when a specific object is queried in a conceptual model. The query in this example returns a single Contact object and all of the related SalesOrderHeader and SalesOrderDetail objects.

To specify the query path, pass a string representation of the object graph to the Include method on the ObjectQuery. The Include method can be applied on top of any Entity Framework query: LINQ to Entities, Entity SQL, or query builder method.

The example in this topic is based on the Adventure Works Sales Model. To run the code in this topic, you must have already added the Adventure Works Sales Model to your project and configured your project to use the Entity Framework. For more information, see How to: Use the Entity Data Model Wizard (Entity Framework) or How to: Manually Configure an Entity Framework Project and How to: Manually Define an Entity Data Model (Entity Framework).


This following example specifies a query path that returns a Contact and related SalesOrderHeader and SalesOrderDetail objects.

The Include method returns the query object, and you can call this method multiple times on an ObjectQuery to include entities from multiple relationships, as in the following example.

See Also