I am attempting to set up a basic model with Parent -> Child relationships (correctly declared and functioning, I believe).
This is my approach:
var parent = new $data.Types.Parent();
$data.context.Parents.add(parent);
parent.Code = 123;
var child = new $data.Types.Child();
$data.context.Childs.add(child);
child.Parent = parent;
child.Value = 456;
However, when trying to access parent.Childs, it returns undefined instead of the array containing the added child.
After saving both entities using:
$data.context.saveChanges();
Upon accessing parent.Childs again, I now get the array [Child]
Having used other ORM tools in the past, it appears that jaydata does not support accessing relationships before saving?
In need of clarification. Thank you!
EDIT:
Observing code on stackoverflow, it seems that I must manually create the Childs array like so:
var parent = new $data.Types.Parent();
$data.context.Parents.add(parent);
parent.Code = 123;
parent.Childs = new Array();
var child = new $data.Types.Child();
$data.context.Childs.add(child);
child.Parent = parent;
child.Value = 456;
parent.Childs.push(child);
Can anyone confirm if this is indeed the correct method for utilizing relationships in jaydata?