2011-12-07 18 views
2

我有Odata服務公開「StartAction」服務操作。此操作返回ActionResponse的實體

<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> 

當我嘗試$擴大行動導航屬性,我得到以下錯誤:

Query options $expand, $filter, $orderby, $inlinecount, $skip and $top cannot be applied to the requested resource 

我周圍的工作,如果我將與只有一個項目返回IQueryable的,但看起來很醜。有誰知道任何其他方式如何使服務操作返回單個實體$擴展工作?

在此先感謝

P.S.該服務具有自定義實現

回答

2

服務操作必須返回IQueryable才能使任何其他查詢選項正常工作(這是必要的,因爲WCF DS需要IQueryable來爲其他查詢選項構造表達式)。 返回帶有單個結果的IQueryable是完全正確的。在服務操作方法上添加[SingleResult]屬性,讓WCF DS知道IQueryable只返回一個值(並且查詢選項相應地起作用)。

+0

謝謝!我已經意識到:) – Konstantin

相關問題