c# - How to display data from many-to-many relationship using odata $expand? -


i have few database tables of them have many-to-many relationships. i'm using webapi , odata fetch data database. instance:

tablea ---> tableb (one one) tablea ---> tablec (one one) tablea ---> tabled (one one) tablee --> tabled ---> table f (many-to-many) 

now, since i'm using odata controller, can use /odata/claims?$expand=tablea,tableb,tablec,tabled displays data expected. however, can't display data tablee , tablef using id's tabled. i'm not sure code show you, here's get method

   [enablequery(allowedqueryoptions =  system.web.odata.query.allowedqueryoptions.all)]     public iqueryable<tablea> get()     {         return dbcontext.deniedclaims.asqueryable();                    } 

is there way can show data tablee , tablef in same query using odata?

this how data shows when $expand

{   "@odata.context":"http://localhost:58891/odata/$metadata#tablea","value":[     {       // values,       "id": 1, // blah blah       "tableb":{           "id":1,"firstname":"test","lastname":"test",       },"tablec":{         "id":1,       },"tabled":{         "id":1,"tableerefid":1,"tablefrefid":1       }     } } 

note tabled, instead of displaying me tableerefid , tablefrefid, want see values in tablee , tablef.

how can this?

if understand data model correctly, want inline expansion more 1 level deep. assuming tabled entity type has navigation properties named tablee , tablef, append nested $expand option tabled follows:

$expand=tableb,tablec,tabled($expand=tablee,tablef) 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -