我有一个数据结构,如:
public abstract class Vehicle { }
public class Car : Vehicle { }
public class MotorCycle : Vehicle { }
与breathjs配合得很好,但是当我想从缓存中获取实体时:
function getLocal() {
var entity = manager.getEntityByKey("Vehicle", id);
}
以“Vehicle”(基类)作为资源参数,找不到实体,而“Car”或“MotorCycle”有效。
我发现,在 getEntityByKey 函数中(breezejs/EntityManager.js)
proto.getEntityByKey = function () {
var entityKey = createEntityKey(this, arguments).entityKey;
var group;
var subtypes = entityKey._subTypes;
if (subtypes) {
for (var i = 0, j = subtypes.length; i < j; i++) {
group = this._findEntityGroup(subtypes[i]);
// group version of findEntityByKey doesn't care about entityType
var ek = group && group.findEntityByKey(entityKey);
if (ek) return ek;
}
} else {
group = this._findEntityGroup(entityKey.entityType);
return group && group.findEntityByKey(entityKey);
}
};
线:
var subtypes = entityKey._subTypes;
_subTypes 用 camelCase 编写并且从未定义,因为该属性被定义为 _subtypes(小写)。如果我更改为 _subtypes,该函数将按预期完美运行。
这是一个错误还是我错过了什么?