angularjs - Cant Save relational Entities in breezejs -
i have 2 entities created through manager.createentity(type);.. z-validate wont display validation errors if try create them otherwise ..entity orderdetails must have valid key order. , later...
... //changed stuff never keys orderdetails.time = new date(); orderdetails.order = order; //am creating relation right here? the app work great offline when save changes server..
manager.savechanges([order,orderdetails]); the sever returning
...orderdetails","keyvalues":["fd...28"],"propertyname":"order",errormessage":"the order field required." any idea how can go through this? have been reading documentations days.
metadata looks this
{ "schema": { "namespace": "inventory.api", "alias": "self", "annotation:usestrongspatialtypes": "false", "xmlns:annotation": "http://schemas.microsoft.com/ado/2009/02/edm/annotation", "xmlns:customannotation": "http://schemas.microsoft.com/ado/2013/11/edm/customannotation", "xmlns": "http://schemas.microsoft.com/ado/2009/11/edm", "cspaceospacemapping": "[\"inventory.api.order\",\"inventory.api.entities.order\"],[\"inventory.api.orderdetail\",\"inventory.api.entities.orderdetail\"],[\"inventory.api.differentdetail\",\"inventory.api.entities.differentdetail\"]", "entitytype": [ { "name": "order", "customannotation:clrtype": "inventory.api.entities.order, inventory.api, version=1.0.0.0, culture=neutral, publickeytoken=null", "key": { "propertyref": { "name": "id" } }, "property": [{ "name": "id", "type": "edm.guid", "nullable": "false", "annotation:storegeneratedpattern": "identity" }, { "name": "barcode", "type": "edm.string", "maxlength": "max", "fixedlength": "false", "unicode": "true" }, { "name": "name", "type": "edm.string", "maxlength": "max", "fixedlength": "false", "unicode": "true" }, { "name": "unitprice", "type": "edm.decimal", "precision": "18", "scale": "2", "nullable": "false" }, { "name": "count", "type": "edm.decimal", "precision": "18", "scale": "2", "nullable": "false" }], "navigationproperty": [{ "name": "orderdetails", "relationship": "self.orderdetail_order", "fromrole": "orderdetail_order_target", "torole": "orderdetail_order_source" }, { "name": "differentdetails", "relationship": "self.differentdetail_order", "fromrole": "differentdetail_order_target", "torole": "differentdetail_order_source" }] }, { "name": "orderdetail", "customannotation:clrtype": "inventory.api.entities.orderdetail, inventory.api, version=1.0.0.0, culture=neutral, publickeytoken=null", "key": { "propertyref": { "name": "id" } }, "property": [{ "name": "id", "type": "edm.guid", "nullable": "false", "annotation:storegeneratedpattern": "identity" }, { "name": "time", "type": "edm.datetime", "nullable": "false" }, { "name": "unitprice", "type": "edm.decimal", "precision": "18", "scale": "2", "nullable": "false" }, { "name": "count", "type": "edm.decimal", "precision": "18", "scale": "2", "nullable": "false" }, { "name": "totalprice", "type": "edm.decimal", "precision": "18", "scale": "2", "nullable": "false" }], "navigationproperty": { "name": "order", "relationship": "self.orderdetail_order", "fromrole": "orderdetail_order_source", "torole": "orderdetail_order_target" } }, { "name": "differentdetail", "customannotation:clrtype": "inventory.api.entities.differentdetail, inventory.api, version=1.0.0.0, culture=neutral, publickeytoken=null", "key": { "propertyref": { "name": "id" } }, "property": [{ "name": "id", "type": "edm.guid", "nullable": "false", "annotation:storegeneratedpattern": "identity" }, { "name": "time", "type": "edm.datetime", "nullable": "false" }, { "name": "unitprice", "type": "edm.decimal", "precision": "18", "scale": "2", "nullable": "false" }, { "name": "count", "type": "edm.decimal", "precision": "18", "scale": "2", "nullable": "false" }, { "name": "totalprice", "type": "edm.decimal", "precision": "18", "scale": "2", "nullable": "false" }], "navigationproperty": { "name": "order", "relationship": "self.differentdetail_order", "fromrole": "differentdetail_order_source", "torole": "differentdetail_order_target" } }], "entitycontainer": { "name": "inventorycontext", "customannotation:useclrtypes": "true", "entityset": [{ "name": "orders", "entitytype": "self.order" }, { "name": "orderdetails", "entitytype": "self.orderdetail" }, { "name": "differentdetails", "entitytype": "self.differentdetail" }], "associationset": [{ "name": "orderdetail_order", "association": "self.orderdetail_order", "end": [{ "role": "orderdetail_order_source", "entityset": "orderdetails" }, { "role": "orderdetail_order_target", "entityset": "orders" }] }, { "name": "differentdetail_order", "association": "self.differentdetail_order", "end": [{ "role": "differentdetail_order_source", "entityset": "differentdetails" }, { "role": "differentdetail_order_target", "entityset": "orders" }] } } }
you need map orderid foreign key property of orderdetail , differentdetail entities. when breeze sends entities server, communicates relationship between entities using foreign keys.
Comments
Post a Comment