문제

Suppose there is person type which has some complex properties such as Address and dateOfBirth

I created a new Entity of person with this code :

 newPerson(manager.createEntity("Person",{ id: breeze.core.getUuid() }));

How can I initiate the complex type so I can bind it to a blank form? In the breeze doc it says :http://www.breezejs.com/documentation/complextype-properties

This is actually slightly incorrect, you can create an ‘unbound’ instance of a complexType with the complexType.createInstance method but when you assign it, you are simply copying its values onto an existing instance.

Where is the best place to initiate the complex type properties?any sample code would be so helpful.

도움이 되었습니까?

해결책

If you are dealing with a scalar navigation property, i.e. a navigation property that returns a single instance of another entity, then you can do it right in the createEntity call

 newDetail = manager.createEntity("OrderDetail", { Order: parentOrder, Product: parentProduct });

If you are dealing with a nonscalar (i.e. array) navigation property then you will need to push the children into the navigation property. i.e.

 newCustomer = em.createEntity("Customer");
 var orders = newCustomer.getProperty("Orders"); 
 orders.push(order1);
 orders.push(order2);
 // OR
 // orders.push.apply(orders, ordersToPush);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top