Note that there are some explanatory texts on larger screens.

plurals
  1. PObreeze: add item to array of complex-type
    text
    copied!<p>I have a breeze class in durandal-project. the class (called "employee") includes property of complex-type (named "mainData"). "main-data" include array of complex-type named "childrenList". the complex-type of the elements of the array named "childDTO". I accept the data from server (c#) and in the client-side (javascript) I want to add and remove items to the array. after that, I want to send the array with the changes to the server, for saving.</p> <p><strong>my question is: how can I add items to array of breeze?</strong></p> <p>here is my classes definitions:</p> <p><strong>employee:</strong></p> <pre><code> addEmployeeType(store); function addEmployeeType(store) { store.addEntityType({ shortName: "EmployeeDTO", namespace: "myServer.Entities", autoGeneratedKeyType: AutoGeneratedKeyType.Identity, dataProperties: { Emp_no1: { dataType: DataType.Int32, isNullable: false, isPartOfKey: true }, employeeBaseData: { name: "employeeBaseData", complexTypeName: "EmployeeBaseDTO:#myServer.Entities", isNullable: false, isPartOfKey: false }, employeeMainData: { name: "employeePersonalDetails", complexTypeName: "EmployeePersonalDetailsDTO:#myServer.Entities", isNullable: true } }); store.registerEntityTypeCtor("EmployeeDTO", null, employeeInit); } </code></pre> <p><strong>MainData:</strong></p> <pre><code> addEmployeeMainDataType(store); function addEmployeeMainDataType(store) { store.addEntityType({ shortName: "EmployeeMainDataDTO", namespace: "myServer.Entities", isComplexType: true, dataProperties: { PermGroup: { dataType: DataType.Int32, isNullable: true, isPartOfKey: false }, Expire_Date: { dataType: DataType.DateTime, isNullable: true, isPartOfKey: false }, ChildrenList: { dataType: DataType.childDTO, isPartOfKey: false, isScalar: false } } }); store.registerEntityTypeCtor("EmployeeMainDataDTO", null, null); } </code></pre> <p><strong>child</strong>:</p> <pre><code> addEmployeeChildType(store); function addEmployeeChildType(store) { store.addEntityType({ shortName: "ChildDTO", namespace: "myServer.Entities", isComplexType: true, dataProperties: { name: { dataType: DataType.String, isNullable: true, isPartOfKey: false }, age: { dataType: DataType.Int32, isPartOfKey: false } } }); store.registerEntityTypeCtor("ChildDTO", null, null); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload