我已升级到最新的breeze版本,现在已经升级到了
function movePropsToBackingStore(instance) {
var bs = getBackingStore(instance);
var proto = Object.getPrototypeOf(instance);
var stype = proto.entityType || proto.complexType;
stype.getProperties().forEach(function(prop) {
var propName = prop.name;
if (!instance.hasOwnProperty(propName)) return;
// pulls off the value, removes the instance property and then rewrites it via ES5 accessor
var value = instance[propName];
delete instance[propName];
instance[propName] = value;
});
return bs;
}
我得到的例外情况 - 无法在严格模式下删除属性! 对于我的一些实体,我已经注册了具有计算属性的CTORS
有解决方法还是错误?
ctor的例子
define(['sharedServices/dataRepository', 'sharedServices/enumRepository'], function (dataRepository, enumRepository) {
'use strict';
return function () {
this.segments = undefined;
var that = this;
function isArray(value) {
return value &&
typeof value === 'object' &&
typeof value.length === 'number' &&
typeof value.splice === 'function' &&
!(value.propertyIsEnumerable('length'));
}
function handlePropertySet(entityName, newState) {
if ((isArray(newState) && newState.length === 0) || (!isArray(newState) && !newState.results)) {
return;
}
var i = 0,
value = isArray(newState) ? newState : newState.results;
for (i; i < value.length; i++) {
dataRepository.addUnchangedEntity(entityName, value[i]);
}
}
function handlePropertyGet(enstate, ename) {
if (that[enstate] === undefined || that[enstate] === null) {
if (!that.entityAspect || !that.entityAspect.entityManager || !that.entityAspect.entityManager.isReady) {
that[enstate] = null;
} else {
that[enstate] = that.entityAspect.entityManager.executeQueryLocally(new breeze.EntityQuery(ename).
where('VirtualTourID', 'eq', that.ID));
}
}
return that[enstate] === null ? [] : that[enstate];
}
Object.defineProperty(this, 'Segments', {
get: function () {
return handlePropertyGet('segments', "VirtualTourSegments");
},
set: function (value) { //used only when loading tours from the server
handlePropertySet('CVirtualTourSegment', value);
},
enumerable: true
});
};
});
删除细分时出错 我也在使用IE11
答案 0 :(得分:0)
我不能重复你的问题。你能发布一个ctor的例子,其中包含一个无法删除的属性吗?
通常,严格模式实际上不会禁止删除属性的实例。但是,请参阅:Why is delete not allowed in Javascript5 strict mode?