Reputation: 110
I have Odata service which exposes "StartAction" service operation. This operation returns ActionResponse entity
<EntityType Name="ActionResponse">
<Key>
<PropertyRef Name="FolderId" />
</Key>
<Property Name="FolderId" Type="Edm.String" Nullable="false" />
<Property Name="ClientData" Type="Edm.String" Nullable="true" />
<Property Name="ProcessCaption" Type="Edm.String" Nullable="true" />
<Property Name="ProcessName" Type="Edm.String" Nullable="true" />
<Property Name="ProjectName" Type="Edm.String" Nullable="true" />
<Property Name="ProjectVersion" Type="Edm.Int32" Nullable="false" />
<Property Name="ServerData" Type="Edm.String" Nullable="true" />
<Property Name="StageName" Type="Edm.String" Nullable="true" />
<Property Name="UserName" Type="Edm.String" Nullable="true" />
<NavigationProperty Name="Action" Relationship="Metastorm.EngineData.ActionResponse_Action_Action_ActionResponse" FromRole="ActionResponse_Action" ToRole="Action_ActionResponse" />
</EntityType>
<Association Name="ActionResponse_Action_Action_ActionResponse">
<End Role="ActionResponse_Action" Type="Metastorm.EngineData.ActionResponse" Multiplicity="0..1" />
<End Role="Action_ActionResponse" Type="Metastorm.EngineData.Action" Multiplicity="0..1" />
</Association>
when i try to $expand Action navigation property, i get the following error:
Query options $expand, $filter, $orderby, $inlinecount, $skip and $top cannot be applied to the requested resource
I can work it around if i will return IQueryable with only one item, but is looks ugly. Does anyone know any other way how to make $expand work for Service Operations which return a single entity?
Thanks in advance
P.S. The service have custom implementation
Upvotes: 2
Views: 1759
Reputation: 13310
The service operation must return IQueryable in order for any of the other query options to work (this is necessary, since WCF DS needs the IQueryable to construct the expression for the additional query options). It is perfectly fine to return an IQueryable with a single result in it. Add the [SingleResult] attribute on the service operation method to let WCF DS know that the IQueryable is only gonna return a single value (and so that the query options behave accordingly).
Upvotes: 2