0

I am using a WCF Data Service and a ASP.NET host, where I have a entity data model for a recipe database. The entity "Recipe" is connected to "Ingredient", which is connected to "Unit". In my client (a windows 8 RT app), I am trying to query the service to get out all ingredients to a recipe, and the unit associated with the ingredient.

private R.juliemrEntities data;

private DataServiceCollection recipes;

var query = (DataServiceQuery)data.Recipes.Expand("Ingredients");

With this query I get the recipes and their ingredients, but I can't manage to expand to the third table, or get a hold of units via ingredients.

Does anyone know how I can write a query that allows me to get a hold of both the recipes, their ingredients and the unit for each ingredient? Help would be greatly appreciated :)

Charles
  • 50,943
  • 13
  • 104
  • 142
Julie Røsok
  • 109
  • 1
  • 4

2 Answers2

1

For a "double expand", use something like this. The second call to expand contains a path-like string to the third entity.

data.Recipes.Expand("Ingredients").Expand("Ingredients/Unit");
wkillerud
  • 31
  • 2
0

If you take a look at http://www.odata.org/documentation/odata-version-3-0/odata-version-3-0-core-protocol 10.2.3.1.3 The $expand System Query Option. you will find that $expand=Ingredients/Unit means expand both ingredients and the unit for each ingredients.

So you can use only one expand

data.Recipes.Expand("Ingredients/Unit");
Layla Liu MSFT
  • 405
  • 2
  • 7