The model (you know, its simple as usual ;)):

[HierarchyRoot]
    public class A : Entity, IHierarchical
    {
        [Key]
        [Field(Nullable = false)]
        public Guid Id { get; set; }

        public Hierarchy Hierarchy { get; set; }

        public Guid? RootId { get; set; }

        [Field]
        [Association(PairTo = "A", OnOwnerRemove = OnRemoveAction.Cascade, OnTargetRemove = OnRemoveAction.Clear)]
        public EntitySet<B> Bs { get; set; }
    }

    [HierarchyRoot]
    public class B : Entity
    {
        [Key]
        [Field(Nullable = false)]
        public Guid Id { get; set; }

        [Field(Nullable = false)]
        [Association(OnTargetRemove = OnRemoveAction.Cascade)]
        public A A { get; set; }
    }

    [HierarchyRoot]
    public class F : Entity
    {
        [Key]
        [Field(Nullable = false)]
        public Guid Id { get; set; }

        [Field(Nullable = false)]
        [Association(OnTargetRemove = OnRemoveAction.Cascade)]
        public C C { get; set; }

        [Field(Nullable = false)]
        [Association(OnTargetRemove = OnRemoveAction.Cascade)]
        public B B { get; set; }
    }

    [HierarchyRoot]
    public class D : Entity
    {
        [Key]
        [Field(Nullable = false)]
        public Guid Id { get; set; }

        [Field(Nullable = true)]
        [Association(OnTargetRemove = OnRemoveAction.Cascade)]
        public E E { get; set; }
    }

    [HierarchyRoot]
    public class E : Entity
    {
        [Key]
        [Field(Nullable = false)]
        public Guid Id { get; set; }
    }

    [HierarchyRoot]
    public class C : Entity
    {
        [Key]
        [Field(Nullable = false)]
        public Guid Id { get; set; }

        [Field(Nullable = false)]
        [Association(OnTargetRemove = OnRemoveAction.Cascade)]
        public A A { get; set; }

        [Field(Nullable = true)]
        [Association(OnTargetRemove = OnRemoveAction.Cascade)]
        public D D { get; set; }

        [Field(Nullable = true)]
        [Association(OnTargetRemove = OnRemoveAction.Cascade)]
        public E E { get; set; }

        [Field]
        [Association(PairTo = "C", OnOwnerRemove = OnRemoveAction.Cascade, OnTargetRemove = OnRemoveAction.Clear)]
        public EntitySet<F> Fs { get; set; }
    }

The code:

Guid id;
using (var t = s.OpenTransaction())
{
    var a = new A();
    var b = new B { A = a };
    var e = new E();
    var d = new D { E = e };

    var c = new C { A = a, D = d, E = e };
    var f = new F() { B = b, C = c };
    id = a.Id;
    t.Complete();
}

using (var t = s.OpenTransaction())
{
    var a = Query.All<A>().Single(r => r.Id == id);

    a.Remove(); // WTF??? UPDATE [dbo].[C] SET [D_Id] = @p1_0, [E_Id] = @p1_1 WHERE ([C].[Id] = @p1_2); @p1_0=NULL,@p1_1=NULL,
    t.Complete();
}

In this code, the C entity is updated to empty reference fields. This is REALLY big problem because it can make unique keys fail etc

asked Apr 26 '12 at 04:31

xumix's gravatar image

xumix
425757682


One Answer:

Hello xumix,

thanks for reporting. Bug is fixed now. It will be included in the next bugfix release of DO.Net

answered Apr 26 '12 at 08:06

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

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