从服务器检索实体和元数据时,我的自定义初始化函数能够按预期访问其导航属性。将元数据和实体导出到localstorage并重新导入它们时,导航属性不可用。我确保在导入之前将ctors和初始化程序注册到metadatastore,因为调用了方法。我看了一下微风源,看来初始化函数是在项目完全填充和附加之前调用的。
targetEntity = entityType._createEntityCore();
updateTargetFromRaw(targetEntity, rawEntity, dataProps, true);
if (newTempKeyValue !== undefined) {
// fixup pk
targetEntity.setProperty(entityType.keyProperties[0].name, newTempKeyValue);
// fixup foreign keys
if (newAspect.tempNavPropNames) {
newAspect.tempNavPropNames.forEach(function (npName) {
var np = entityType.getNavigationProperty(npName);
var fkPropName = np.relatedDataProperties[0].name;
var oldFkValue = targetEntity.getProperty(fkPropName);
var fk = new EntityKey(np.entityType, [oldFkValue]);
var newFkValue = tempKeyMap[fk.toString()];
targetEntity.setProperty(fkPropName, newFkValue);
});
}
}
*targetEntity.entityAspect._postInitialize();*
targetEntity = entityGroup.attachEntity(targetEntity, entityState);
if (entityChanged) {
entityChanged.publish({ entityAction: EntityAction.AttachOnImport, entity: targetEntity });
if (!entityState.isUnchanged()) {
entityGroup.entityManager._notifyStateChange(targetEntity, true);
}
}
}
if (targetEntity) {
targetEntity.entityAspect.entityState = entityState;
if (entityState.isModified()) {
targetEntity.entityAspect.originalValuesMap = newAspect.originalValues;
}
entityGroup.entityManager._linkRelatedEntities( targetEntity);
}
如果我在._linkRelatedEntities调用下移动帖子初始化调用,它似乎与查询实现完全一样
if (targetEntity) {
targetEntity.entityAspect.entityState = entityState;
if (entityState.isModified()) {
targetEntity.entityAspect.originalValuesMap = newAspect.originalValues;
}
entityGroup.entityManager._linkRelatedEntities( targetEntity);
*targetEntity.entityAspect._postInitialize();*
}
我在这里遗漏了什么吗?这是设计的功能吗?我通过传入EntityManager找到了解决方法,设置了entityAspect管理器并调用了loadNavigationProperties但是这似乎是多余的。对Breeze人员的任何见解都将不胜感激。
谢谢, 布拉德
答案 0 :(得分:0)
不确定,但此问题可能与我们刚刚在Breeze 1.4.1中修复的错误有关。