Search code examples
asp.net-web-apiodatabreeze

Breeze 1.3.5 with odata and Navigation properties


I am using Microsoft WebAPI OData nightly that supports $expand and breeze 1.3.5 to query the data

When I use breeze to query the entity: via breeze.EntityQuery.from("Incidents").where("IncidentID", "eq", 1).expand("IncidentComments");

the call on the wire is GET /odata/Incidents?$filter=IncidentID%20eq%201&$expand=IncidentComments

The result is correctly returned from the server with the collection of IncidentComments but when I view the entity retuned from the query I get the entity correctly but without the NavigtaionProperty (IncidentComments), when I look at the metadataStore on the Incident entity I can't see any nvigationProperties only dataProperties in the metadata

When I look at the odata metadata ($metadata) returned from the server I can see the navigation properties are there:

<EntityType Name="Incident">
    <Key>
      <PropertyRef Name="IncidentID" />
    </Key>
    <Property Name="IncidentID" Type="Edm.Int32" Nullable="false" />
    <Property Name="IncidentType" Type="Edm.Int32" Nullable="false" />
    <Property Name="Name" Type="Edm.String" />
    <NavigationProperty Name="IncidentComments" Relationship="Stabilis.Situator.OpServerTypes.Stabilis_Situator_OpServerTypes_Incident_IncidentComments_Stabilis_Situator_OpServerTypes_IncidentComment_IncidentCommentsPartner" ToRole="IncidentComments" FromRole="IncidentCommentsPartner" />

is there something wrong with the metadata returned from the webapi?


Solution

  • Yes, there is something wrong with the metadata from the Web API OData. It is missing the foreign keys that support those navigations!!!

    WCF OData metadata provides the FK information ... which is why Breeze works with that kind of OData source. But the FK info are missing from the Web API OData metadata as of this writing. We are talking to the team about that.

    We expect to have some resolution ... perhaps a workaround in which you tell Breeze what the FK properties are. We don't have a schedule for that effort.

    Remember: these are pre-release Microsoft bits you're playing with.