I have a .NET WebAPI 2 Odata service and i am working with Breeze on top of it The OData service is based on the VS2013 ASP.Net VNext version The service supports expand I managed to trick the Microsoft OData metadata serialize to provide the referential constraint with the foreign key like so:
<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>
The problem is that the web API odata returns expand result within an extra result element and not directly as a jason array like so:
"__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"
}
is there a way to configure breeze to handle that correctly?
If i have a navigation property only within one element without a reverse property on the other side, for example in my case an incident holding a collection of task but a task not needing to have a reference to the incident, Breeze does not seems to support that correctly, is there a way to configure that?