我发现了一个关于ComplexType属性的错误。我有一个对象,它有一个属性,它是我在客户端元数据中定义为复杂属性的其他对象的集合,即"isComplexType: true“。但是,复杂类型的所有属性都设置为“未定义”。我做了一些调试,发现了以下内容:
// target and source may not be entities that can also be complexTypes.
function updatePropertyFromRawEntity(dp, target, rawSource) {
var val = getPropertyFromRawEntity(rawSource, dp);
if (val === undefined) return;
if (dp.isComplexProperty) {
var coVal = target.getProperty(dp.name);
dp.dataType.dataProperties.forEach(function (cdp) {
// recursive call
updatePropertyFromRawEntity(cdp, coVal, val);
});
} else {
target.setProperty(dp.name, val);
}
}rawSource参数是一个数组(在complexTypes的情况下)是一个对象数组。所以问题是,当调用getPropertyFromRawEntity()时,它传递的是数组而不是对象:
function getPropertyFromRawEntity(rawEntity, dp) {
var propName = dp.nameOnServer || dp.isUnmapped && dp.name;
return parseValueForDp(rawEntity[propName], dp);
}所以rawEntitypropName永远是未定义的,因为它是一个数组。
发布于 2013-05-14 01:46:11
微风ComplexType具有由元数据指定的定义良好的结构。任何属性(键除外)的数据类型都可以是complexType。然而,我认为你想要的是一个“无类型”的结构。这可以通过将属性定义为具有“未定义”的数据类型来实现,如下所示:
var newProp = new DataProperty({
name: "Foo"
dataType: DataType.Undefined,
isNullable: true,
isUnmapped: true
});
entityType.addProperty(newProp);“未定义的”dataType将接受任何类型和结构的数据。
https://stackoverflow.com/questions/16519566
复制相似问题