我同時使用PowerQuery上OData服務我目前正在開發得到這個錯誤:的OData函數返回實體的集合失敗PowerQuery
當編寫一個JSON響應,必須指定一個用戶模型和 必須將實體集和實體類型傳遞給 ODataMessageWriter.CreateODataEntryWriter方法,或者必須在正在寫入的ODataEntry或 ODataFeed上設置ODataFeedAndEntrySerializationInfo。
從PowerQuery調用返回實體集合的綁定函數時會發生這種情況。當從Web瀏覽器調用時,響應爲(JSON格式):
{
"@odata.context": "http://localhost:8080/ODataPrototype/ODataPrototype.svc/$metadata#Collection(Demo.ODataPrototype.Count)",
"value": [
{
"RowCount": 1
},
{
"RowCount": 2
},
{
"RowCount": 3
},
{
"RowCount": 4
}
]
}
我使用Olingo V4庫。我的元數據的精簡版將是:
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
<edmx:DataServices>
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Demo.ODataPrototype">
<EntityType Name="Instance">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property Name="Id" Type="Edm.Int32"/>
<Property Name="Name" Type="Edm.String"/>
<Property Name="Description" Type="Edm.String"/>
<Property Name="Tag" Type="Edm.String"/>
<Property Name="Xid" Type="Edm.Int64"/>
<Property Name="Properties" Type="Collection(Demo.ODataPrototype.Property)"/>
</EntityType>
<EntityType Name="Count">
<Property Name="RowCount" Type="Edm.Int32"/>
</EntityType>
<ComplexType Name="Property">
<Property Name="Name" Type="Edm.String"/>
<Property Name="Value" Type="Edm.String"/>
</ComplexType>
<Function Name="GetData" EntitySetPath="Instance/Demo.ODataPrototype.Count" IsBound="true">
<Parameter Name="Instance" Type="Demo.ODataPrototype.Instance"/>
<Parameter Name="From" Type="Edm.DateTimeOffset"/>
<Parameter Name="To" Type="Edm.DateTimeOffset"/>
<ReturnType Type="Collection(Demo.ODataPrototype.Count)"/>
</Function>
<EntityContainer Name="Container">
<EntitySet Name="Instances" EntityType="Demo.ODataPrototype.Instance">
</EntitySet>
<EntitySet Name="Count" EntityType="Demo.ODataPrototype.Count"/>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
有人知道我失蹤了嗎?