无法从缓存中找到子类型实体

时间:2013-07-07 20:41:53

标签: breeze

我的数据结构如下:

public abstract class Vehicle { }
public class Car : Vehicle { }
public class MotorCycle : Vehicle { }

与breezejs配合得很好,但是当我想从缓存中获取实体时:

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(lowerCase)。 如果我更改为_subtypes,则该函数将按预期完美地运行。

这是一个错误还是我错过了什么?

1 个答案:

答案 0 :(得分:1)

看起来像个错误。我们在下一个版本中修复此问题。 ...并且感谢您找到它。 :)