New Breeze 1.4.9-重复的实体-可能的错误? [英] New Breeze 1.4.9 - Duplicate entity - possible bug?

查看:48
本文介绍了New Breeze 1.4.9-重复的实体-可能的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在升级到Breeze 1.4.9之后,此问题开始出现。

This problem started appearing after I upgraded to Breeze 1.4.9.

我具有以下实体:

public class ProjectMember
{
    public int ProjectId { get; set; }
    [ForeignKey("ProjectId")]
    [InverseProperty("ProjectMembers")]
    public Project Project { get; set; }

    public int TeamMemberId { get; set; }
    [ForeignKey("TeamMemberId")]
    [InverseProperty("ProjectMembers")]
    public TeamMember TeamMember { get; set; }
}

及其配置:

public class ProjectMemberConfiguration : EntityTypeConfiguration<ProjectMember>
{
    public ProjectMemberConfiguration()
    {
        HasKey(a => new { a.ProjectId, a.TeamMemberId });

        // ProjectMember has 1 project, projects have many projectmember records
        HasRequired(a => a.Project)
            .WithMany(s => s.ProjectMembers)
            .HasForeignKey(a => a.ProjectId)
            .WillCascadeOnDelete(true);
    }
}

元数据如下:

我在客户端使用以下代码创建该实体:

I create this entity on the client side with the following:

manager.createEntity('ProjectMember', { projectId: projectId, teamMemberId: teamMemberId });

到目前为止一切都很好,但是当该实体保存回服务器时,它会在客户端上重复侧面,如belo所示(下面的屏幕截图显示了 saveChanges 成功 c回调之后的缓存中的内容。

All good so far, however when this entity is saved back to the server it gets duplicated on the client side as shown belo (the screenshot below shows what is in the cache after saveChanges succeeded callback is reached.

问题
为什么Breeze尽管不应该允许重复该实体?

QUESTION Why is Breeze duplicating this entity although it should not be allowed?

编辑

我回到了Breeze 1.4.8,问题消失了,这是经理在保存操作之后包含:

I reverted back to Breeze 1.4.8 and the problem disappeared. Here is what the manager contains after a save operation:

推荐答案

2014年3月7日更新



这是一个错误,现已修复,可以在GitHub上使用。在接下来的几天内将以完整的zip发行。高于1.4.9的n应该包含此修复程序。

Updated March 7 2014

This was a bug and is now fixed and available on GitHub. It will be released with a complete zip within the next few days. Any version above 1.4.9 should contain the fix.

抱歉,我不能从屏幕截图显示任何重复的内容。您是否在EntityManager缓存中看到两个具有相同键的实体,如果是,怎么办?您还在数据库上看到某种形式的重复吗?

Sorry, I can't tell from the screenshots that anything is duplicated. Are you seeing two entities in the EntityManager cache with the same key, And if so how?. Are you also seeing some form of duplication on the database as well?

还是保存后在客户端上创建了新实体的问题?

Or is the problem that a 'new' entity is being created on the client after the save?

这些键的一部分是否可能是数据库上的标识列?如果是这样,那么值得检查元数据以确保将此EntityType的autoGeneratedKeyType属性设置为 Identity 。这将导致数据库在插入时生成新的密钥,然后将该实体发送回客户端。仅当AutoGeneratedKeyType设置为 Identity 时,才会将该实体与其先前的化身合并。否则,您将最终获得带有旧密钥的原始实体和一个具有其新密钥的克隆版本。

Is it possible that one part of these keys is an Identity column on the database? If so, then it's worth checking the metadata to insure that the autoGeneratedKeyType property for this EntityType is set to Identity. This would cause the database to generate a new key on insert and this entity would then be sent back to the client. Merging this entity with its previous incarnation will only occur if the AutoGeneratedKeyType is set to Identity. Otherwise, you will end up with both the original entity with the old key and a cloned version its new key.

否则,我认为我们需要更多信息。

Otherwise, I think we need more information.

这篇关于New Breeze 1.4.9-重复的实体-可能的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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