Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

As indicated in the Entity Framework image below, I have 3 tables, tblModel, tblModelFetish and tblFetish. A record in tblModel can have multiple records in the tblModelFetish table linked by the modelid column. The tblModelFetish table links to the tblFetish table via the fetishID column to get the fetish description stored in the fetish column. This Entity Model was generated with VS 2010 from an existing database including foreign keys.

a Entity Data Model

Using the odata syntax, I'm able to access all models (http://localhost:51157/WcfDataService.svc/tblModels) or a specific model (http://localhost:51157/WcfDataService.svc/tblModels(11)) successfully. I'm having trouble accessing the related tables data via odata, I've tried many permutations including expand etc.

What I want is a result set of all the columns in the tblModel and the related tblFetish records including the fetish column from the tblFetish table. In other words, Mary (a modelname in tableModel) has 3 fetishes (3 records in tblModelFetish) named beach, travel and coffee (stored in tblFetish, fetish column).

What is the odata syntax to acquire this?

thanks for reading! Bob

share|improve this question

1 Answer

up vote 0 down vote accepted

Try either:

http://localhost:51157/WcfDataService.svc/tblModels(11)?$expand=tblModelFetishes/tblFetish

or

http://localhost:51157/WcfDataService.svc/tblModels?$filter=id eq 11&$expand=tblModelFetishes/tblFetish

Just to make it clear you will not get one huge result set with all columns but the entity graph consisted of your entities.

share|improve this answer
 
Thank you Ladislav –  Bob Feb 24 '12 at 21:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.