DO version: 5.0.0.850

Has error on remove item with cascade link

/// <summary>
/// Base
/// </summary>
[Serializable]
[HierarchyRoot]
public abstract class Entity0 : ReferenceBase
{
    protected Entity0(Guid id)
        : base(id)
    {
    }

    /// <summary>
    /// Field
    /// </summary>
    [Field]
    public string Field { get; set; }
}

/// <summary>
/// Entity1
/// </summary>
[Serializable]
public abstract class Entity1 : Entity0
{
    protected Entity1(Guid id)
        : base(id)
    {
    }

    /// <summary>
    /// Tp
    /// </summary>
    [Field]
    [Association(PairTo = "Owner", OnOwnerRemove = OnRemoveAction.Cascade, OnTargetRemove = OnRemoveAction.Clear)]
    public EntitySet<TpEntity> Tp { get; set; }

    /// <summary>
    /// Tp
    /// </summary>
    [HierarchyRoot]
    [Serializable]
    [Id("42BBB145-F343-419A-0000-000000000000")]
    public class TpEntity : TablePartBase<Entity1>
    {
        public TpEntity(Guid id, Entity1 owner)
            : base(id, owner)
        {
        }

        /// <summary>
        /// TpField
        /// </summary>
        [Field]
        public string TpField { get; set; }
    }
}

/// <summary>
/// Entity2
/// </summary>
[Serializable]
public abstract class Entity2 : Entity1
{
    protected Entity2(Guid id)
        : base(id)
    {
    }
}

/// <summary>
/// Entity3
/// </summary>
[Serializable]
public class Entity3 : Entity2
{
    public Entity3(Guid id)
        : base(id)
    {
    }
}

Exception:

SQL error occured.
Storage error details 'Entity: Entity1.TpEntity; Field: Owner.Id (FieldInfo);'
SQL error details 'Type: ReferentialConstraintViolation; Database: DO40-Tests; Table: Entity1.TpEntity; Column: Owner.Id; Constraint: FK_Entity1.TpEntity_Owner_Entity1;'
Query 'DELETE FROM [dbo].[Entity3] WHERE ([Entity3].[Id] = @p1_0);
DELETE FROM [dbo].[Entity2] WHERE ([Entity2].[Id] = @p1_0);
DELETE FROM [dbo].[Entity1] WHERE ([Entity1].[Id] = @p1_0);
DELETE FROM [dbo].[Entity0] WHERE ([Entity0].[Id] = @p1_0);
DELETE FROM [dbo].[Entity1.TpEntity] WHERE ([Entity1.TpEntity].[Id] = @p2_0); [p1_0='1865b929-9501-442d-91b7-22294bd93ca5';p2_0='a714b7f8-e5b0-413f-813b-0890369afd17']'
Original message 'The DELETE statement conflicted with the REFERENCE constraint \"FK_Entity1.TpEntity_Owner_Entity1\". The conflict occurred in database \"DO40-Tests\", table \"dbo.Entity1.TpEntity\", column 'Owner.Id'.
The DELETE statement conflicted with the REFERENCE constraint \"FK_Entity1_Entity0\". The conflict occurred in database \"DO40-Tests\", table \"dbo.Entity1\", column 'Id'.
The statement has been terminated.

asked Aug 01 '14 at 07:09

Anton%20Guschin's gravatar image

Anton Guschin
73233035


One Answer:

Hi Anton Guschin.

This bug already fixed in 5.0.0-RC.

answered Aug 04 '14 at 02:08

Alexey%20Kulakov's gravatar image

Alexey Kulakov
48215

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA