Search code examples
c#entity-framework-6odatawcf-data-servicesservice-reference

OData $expand URL limit?


How do you expand navigation properties of an entity through a service reference when you have a lot (20 in this case) of navigation properties to expand? I am executing the following code:

var result = MyEntities.Sample.Expand("Collector,Container,Coordinates...") 

this results in the following URI:

http://192.168.0.196/Service.svc/Sample?$expand=Collector,Container,Coordinates,DispositionRequest,Employee,EstimatedSampleVolume,Facility,PreparationSize,Priority,Product,SourceLocation,SampleClassification,Unit,Vendor,Unit,WorkOrder,SampleType,Subject,Site,State

The error I am getting is:

$expand does not support '19' properties expanded simultaneously on the same segment.

Solution

  • It looks like no more than 13 simultaneously expanded properties is not currently supported in the OData protocol.

    https://github.com/OData/odata.net/blob/ODATAV3/WCFDataService/Service/System/Data/Services/WebUtil.cs#L986-L990