breezejs v1.3.6破坏了我的应用程序 [英] breezejs v1.3.6 breaks my application

查看:64
本文介绍了breezejs v1.3.6破坏了我的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将客户端库和服务器Web API dll更新为最新版本.

I've updated my client library and server web api dll to latest version.

现在,每当对查询进行扩展时,都会出现这种错误:

Now whenever I do an expand on a query, I get that kind of error:

unable to locate property: Mandate on type: MandateHistory:#Dom.DirectDebit

查询为:

  var query = breeze.EntityQuery.from("MandatesHistory")
        .where("Mandate.Id", "==", mandatId).expand("Mandate"); 

    return manager.executeQuery(query.using(service));

如果我降级到1.3.3(仅客户端库),一切正常.

If I downgrade to 1.3.3 (the client library only), everything works fine.

我想尝试1.3.4或1.3.5,但在网站上找不到它们....

I would have like to try 1.3.4 or 1.3.5 but I can't find them on the website....

在1.3.3和1.3.6之间发生了什么变化,可能会破坏我的应用程序?

What has changed between 1.3.3 and 1.3.6 that could break my application ?

编辑

这是代码引起的问题:

在1.3.6中,在函数parseCsdNavProperty中,添加了以下代码:

In 1.3.6, in the function parseCsdNavProperty, the following code was added:

 var constraint = association.referentialConstraint;
    if (!constraint) {
        // TODO: Revisit this later - right now we just ignore many-many and assocs with missing constraints.
        return;
        // Think about adding this back later.
        //if (association.end[0].multiplicity == "*" && association.end[1].multiplicity == "*") {
        //    // many to many relation
        //    ???
        //} else {
        //    throw new Error("Foreign Key Associations must be turned on for this model");
        //}
    }

基本上,对于导航属性MandateHistory.Mandate,没有找到约束,因此代码仅返回.这是造成我问题的原因.

Basically, for the navigation property MandateHistory.Mandate, there is no contraint found, so the code just return. This is the cause of my issue.

在1.3.3版中,没有检查约束,因为首先存在以下检查,在我的情况下该检查返回false(isScalar为false):

In version 1.3.3, there was no check on constraint because first there was the following check which returns false in my case (isScalar is false):

 if (toEnd && isScalar) {
        var constraint = association.referentialConstraint;
        if (constraint) {
            var principal = constraint.principal;
            var dependent = constraint.dependent;
            var propRefs;
            if (csdlProperty.fromRole === principal.role) {
                propRefs = toArray(principal.propertyRef);
            } else {
                propRefs = toArray(dependent.propertyRef);
            }
            // will be used later by np._update
            fkNamesOnServer = propRefs.map(__pluck("name"));
        }
    }

微风团队可以对此进行调查吗?

Can the breeze team look into this ?

解决方案

按照Jay的建议,必须更改.net模型,以便显式设置MandateHistory和Mandate之间的外键关联:

Following Jay's suggestion, the .net model had to be changed in order to explicitly set the foreign key association between MandateHistory and Mandate:

 public class MandateHistory
 {
    [ForeignKey("Mandate")]
    public int Mandate_Id { get; set; }

    public virtual Mandate Mandate { get; set; }
 }

推荐答案

我的猜测是您在模型中缺少引用约束.即实体框架认为您没有公开外键.参见外键在实体框架中.

My guess is that you are missing referential constraints in your model. i.e. the Entity Framework thinks that you are not exposing foreign keys. See Foreign keys in the Entity Framework.

微风需要外键才能执行其自动对象链接逻辑.

Breeze requires the foreign keys in order to perform it's automatic object linking logic.

此处也对此进行了描述:微风导航属性

This is also described here: Breeze navigation properties

这篇关于breezejs v1.3.6破坏了我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆