此问题具有标量复杂属性,之前已报告并在微风1.3.5中得到解决。 我仍然在微风1.4.5中看到非标量复杂属性。使用此元数据创建实体后,实体管理器上的exportEntities()方法失败,JSON.stringify中出现异常,抱怨循环引用。
以下是一些复制问题的代码:
var jsonMetadata = {
"metadataVersion": "1.0.5",
"namingConvention": "camelCase",
"localQueryComparisonOptions": "caseInsensitiveSQL",
"dataServices": [{"serviceName": "breeze/myservice/" } ],
"structuralTypes": [
{
"shortName": "Address",
"namespace": "mynamespace",
"isComplexType": true,
"dataProperties": [
{"name": "street"},
{"name": "city"},
]
},
{
"shortName": "Person",
"namespace": "mynamespace",
"autoGeneratedKeyType": "Identity",
"defaultResourceName": "Person",
"dataProperties": [
{"name": "_id", "dataType": "MongoObjectId", "isNullable": false, "defaultValue": "",
"isPartOfKey": true },
{"name": "displayName", "dataType": "String"},
{ "name": "addresses",
"complexTypeName": "Address:#mynamespace",
"isScalar": false
}
]
}
],
"resourceEntityTypeMap": {
"Person": "Person:#mynamespace"
}};
var manager = new breeze.EntityManager();
manager.metadataStore.importMetadata(jsonMetadata);
var person = manager.createEntity('Person', {displayName: "Joe Bob"});
var myAddresses = person.getProperty('addresses');
var myAddressProp = manager.metadataStore.getEntityType("Address").createInstance(
{street: "Main", city:"Pleasantville"});
myAddresses.push(myAddressProp);
console.log("Complex property is a circular datatype, cannot convert to JSON - that's fine")
//JSON.stringify(person.addresses); // fails with error
console.log("... except that manager.exportEntities() doesn't handle that case!");
var entities = manager.exportEntities(); // also fails
JSON.stringify抱怨的循环引用似乎位于Address属性的ComplexAspect的“parent”属性中。
另外,如果有一种更简单的方法来填充地址数组,我会感激一些帮助。
答案 0 :(得分:0)
好的,这应该在Breeze v 1.4.6(或更高版本)现在可以修复
-------------原帖------------------
这是一个错误。它将在下一个版本中修复,本周晚些时候或下周初。并且...感谢repro。我会在它进入时回复。