Search code examples
jsonasp.net-web-apiodataasp.net-web-api-odata

$select returning empty json result for Navigation Property


i am using v4 of oData in an web api.

my get all call returns the entire set (total 3 objects) properly.

http://localhost:9910/api/CommandsRest

enter image description here

but trying to select just the StoreCommand gives me 3 blank objects

http://localhost:9910/api/CommandsRest?$select=StoreCommand

trying to expand StoreCommand gives me StoreCommand but does not gives me its Navigation Properties

http://localhost:9910/api/CommandsRest?$expand=StoreCommand

i want just the StoreCommand property of the main Object with all its Navigation Properties.


Solution

  • Try /CommandsRest?$select=StoreCommand&$expand=StoreCommand($expand=DictionaryVariables). This will get you each StoreCommand with the DictionaryVariables property expanded inline.

    If you want all of the navigation properties of StoreCommand, you must list them explicitly in the nested expand clause. E.g., $expand=DictionaryVariables,DictionaryNestedSplitVariables,DictionaryMultipleVariables,TabularVariables.

    Note that I tested these URIs using in memory data, not MongoDB.