我有一个.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