This project is read-only.

IQueryable and OData $expand

Topics: Web Api
Jul 8, 2011 at 2:23 AM
Edited Jul 8, 2011 at 2:31 AM

I was creating a sample project to test the OData $expand commands and how they function with WCF Web Api. I had a bit of a interesting encounter.

I'm using EF 4.1, I just used an existing database to create my model, at this point the model had no relationships between the tables. Accessing http://localhost:10000/test?$filter=Ref_No eq 129628 worked fine, I got the expected data back.

Then I added a 1 to Many assocation to the model, and tried to access the same URL I got the following error to my surprise:

Cannot serialize member ApiSpikes.Infrastructure.Base.Features of type System.Collections.Generic.ICollection`1 
[[ApiSpikes.Infrastructure.Feature, ApiSpikes, Version=, Culture=neutral, PublicKeyToken=null]] 
because it is an interface.

Im I missing a step here? Or is this serialization not implemented currently? If not, I'm guessing I have to write my own formatter to resolve this issue? 

Jul 8, 2011 at 2:29 AM

Hi Bhavik

Expansions are not supported currently.