1
我最近已更新到Breezejs 1.4.2,并且运行自定义初始值设定项似乎存在问题。我的应用使用Breeze正确注册了ctor和initializer(我相信),但是当我从entityframework支持的webapi检索记录时,初始化程序并未执行。从github的签入源看来,初始化代码已被注释掉,并且注释将从另一段代码执行初始化程序。任何想法如何我可以解决这个问题?在工作时我可能会降级到1.4.1。我将删除注释掉的部分,看它是否有效,但想知道是否有其他人在那里体验相同的事情?Breezejs ComplexType不执行自定义初始值设定项功能
C#
public class ForecastItem
{
public int Id { get; set; }
public Result CurrentYear { get; set; }
/* extra detail removed */
}
public class Result
{
public int? Actual { get; set; }
public int? Estimate { get; set; }
}
的Javascript
function extendResult(metadataStore) {
var ctor = function() { };
var initialiser = function (entity) {
entity.useEstimate = ko.computed({
read: function() {
return entity.actual() === -1 ? true : false;
},
deferEvaluation: true
});
return entity;
};
metadataStore.registerEntityTypeCtor('Result', ctor, initialiser);
}
编辑
我已经注释掉了从breeze.debug.js的代码和它现在的工作。
的ComplexType原obejct
proto._createInstanceCore = function (parent, parentProperty) {
var aCtor = this.getCtor();
var instance = new aCtor();
new ComplexAspect(instance, parent, parentProperty);
// TODO: don't think that this is needed anymore - createInstance call will do this
//if (parent) {
// this._initializeInstance(instance);
//}
return instance;
};