Question

I have next classes:

public class Event
{
   public int Id { get; set; }
   public string Title { get; set; }
   public string Description { get; set; }
   public List<ImageLink> Images { get; set; }
}

public class ImageLink
{
   public int Id { get; set; }
   public string Url { get; set; }
}

My action:

public IQueryable<Event> GetEvents()
{
    var events = EventsRepository.Events.AsQueryable();
    return events;
}

EventsRepository.Events - returns me events with many imageslink, but in brouser I doesn't see them:

 "odata.metadata":"http://localhost:28286/odata/$metadata#Events","value":[
    {
      "Title":"Title", 
      "Description":"Description"
    },...

I know that Odata have $expand option, but seems it's not supported yet. How can I force my application to return deep serializable object? Because I want to get all included data in my client.

Was it helpful?

Solution

If ImageLink were modeled as a complex type the response payload for Event would contain ImageLink inline. You could tell the modelbuilder to map ImageLink as a complex type using,

modelBuilder.ComplexType<ImageLink>();

The proper way to do this though is to use $expand. We are working in $select and $expand support right now and should have working bits in the nightly builds early next week.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top