我有一個.NET的WebAPI 2 OData服務,我有微風在它的頂部 工作的OData服務是基於VS2013 ASP.Net VNext版本 該服務支持擴大 我管理欺騙微軟的OData元數據序列化提供參照約束與外鍵,像這樣:微風使用Web API的OData工作
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="3.0" m:MaxDataServiceVersion="3.0">
<Schema xmlns="http://schemas.microsoft.com/ado/2009/11/edm" Namespace="ODataGame.Models">
<EntityType Name="Incident">
<Key>
<PropertyRef Name="ID"/>
</Key>
<Property Name="ID" Type="Edm.Int32" Nullable="false"/>
<Property Name="Name" Type="Edm.String"/>
<Property Name="Desc" Type="Edm.String"/>
<NavigationProperty Name="DTask" Relationship="ODataGame.Models.ODataGame_Models_DTask_DTaskPartner_ODataGame_Models_Incident_DTask" ToRole="DTask" FromRole="Incident"/>
</EntityType>
<EntityType Name="DTask">
<Key>
<PropertyRef Name="ID"/>
</Key>
<Property Name="ID" Type="Edm.Int32" Nullable="false"/>
<Property Name="Name" Type="Edm.String"/>
<Property Name="IncidentID" Type="Edm.Int32" Nullable="false"/>
<NavigationProperty Name="Incident" Relationship="ODataGame.Models.ODataGame_Models_DTask_DTaskPartner_ODataGame_Models_Incident_DTask" ToRole="Incident" FromRole="DTask"/>
</EntityType>
<Association Name="ODataGame_Models_DTask_DTaskPartner_ODataGame_Models_Incident_DTask">
<End Type="ODataGame.Models.Incident" Role="Incident" Multiplicity="0..1"/>
<End Type="ODataGame.Models.DTask" Role="DTask" Multiplicity="*"/>
<ReferentialConstraint>
<Principal Role="Incident">
<PropertyRef Name="ID"/>
</Principal>
<Dependent Role="DTask">
<PropertyRef Name="IncidentID"/>
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="ODataGame_Models_DTask_Incident_ODataGame_Models_Incident_IncidentPartner">
<End Type="ODataGame.Models.Incident" Role="Incident" Multiplicity="0..1"/>
<End Type="ODataGame.Models.DTask" Role="DTask" Multiplicity="0..1"/>
</Association>
<EntityContainer Name="Container" m:IsDefaultEntityContainer="true">
<EntitySet Name="Incident" EntityType="ODataGame.Models.Incident"/>
<EntitySet Name="DTask" EntityType="ODataGame.Models.DTask"/>
<AssociationSet Name="ODataGame_Models_DTask_DTaskPartner_ODataGame_Models_Incident_DTaskSet" Association="ODataGame.Models.ODataGame_Models_DTask_DTaskPartner_ODataGame_Models_Incident_DTask">
<End Role="Incident" EntitySet="Incident"/>
<End Role="DTask" EntitySet="DTask"/>
</AssociationSet>
<AssociationSet Name="ODataGame_Models_DTask_DTaskPartner_ODataGame_Models_Incident_DTaskSet" Association="ODataGame.Models.ODataGame_Models_DTask_DTaskPartner_ODataGame_Models_Incident_DTask">
<End Role="DTask" EntitySet="DTask"/>
<End Role="Incident" EntitySet="Incident"/>
</AssociationSet>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
的問題是,網絡API的OData收益擴大的結果額外的結果元素中,並不能直接作爲賈森陣列狀所以:
"__metadata":{
"id":"http://localhost:27698/odata/Incident(3)","uri":"http://localhost:27698/odata/Incident(3)","type":"ODataGame.Models.Incident"
},"DTask":{
"results":[
{
"__metadata":{
"id":"http://localhost:27698/odata/DTask(1)","uri":"http://localhost:27698/odata/DTask(1)","type":"ODataGame.Models.DTask"
},"Incident":{
"__deferred":{
"uri":"http://localhost:27698/odata/DTask(MEIR%20MISSING)/Incident"
}
},"ID":1,"Name":"kk","IncidentID":3
}
]
},"ID":3,"Name":"asas","Desc":"zz"
}
有沒有辦法配置breeze來正確處理?
如果我有一個導航屬性只在一個元素沒有另一邊的反向屬性,例如在我的情況下事件持有任務的集合,但不需要事件的引用任務,Breeze做似乎沒有正確支持,有沒有一種方法來配置?
您是否解決了關於未被微風處理的額外結果元素的問題?我在這裏有同樣的問題:http://stackoverflow.com/questions/19060244/breezejs-navigation-property-is-created-but-not-filled-with-data – Sam
你能分享你如何欺騙OData電火花序列化器包含ReferentialConstraint?由於缺少約束條件,我無法輕易識別1-m關聯。 – khaledh