1

我最近更新到 Breezejs 1.4.2,运行自定义初始化程序似乎存在问题。我的应用程序使用 Breeze 正确注册了 ctor 和初始化程序(我相信),但是当我从实体框架支持的 webapi 检索记录时,初始化程序没有被执行。从github的签入源看来,初始化程序代码已被注释掉,并带有一条注释,即初始化程序将从另一段代码执行。有什么想法可以解决这个问题吗?我可能会降级到 1.4.1,因为它正在工作。我将删除注释掉的部分,看看它是否有效,但想知道是否还有其他人经历过同样的事情?

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);
    }

编辑
我已经取消注释掉来自轻风.debug.js 的代码,它现在正在工作。

ComplexType 原型对象

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;
};
4

1 回答 1

1

好的,这是一个错误并已修复。该修复程序将在 Breeze 1.4.3 中提供,或者现在可以从 Breeze Git 存储库中获得。...感谢您找到它。:)

于 2013-10-04T21:42:31.630 回答