Is this bug?

Topics: Developer Forum, User Forum
Oct 14, 2009 at 3:31 AM

When I removed an item from the HasMany<T> list and then called Save(), it didn't delete the record from the DB. Then I found line 507~516 in the DbContext.cs as below:

                                    if (f.IsHasMany)
                                        var ho2 = (IHasMany)ho;
                                        foreach (object item in ho2.RemovedValues)

                                    CommonHelper.TryEnumerate(llo, e2);

Is it a bug? Should the line 512 "Save(item)" be corrected to "Delete(item)"? Thank you!


Oct 14, 2009 at 8:32 AM

It's not a bug.

It just remove the relation of them when you call HasMany<T>.Remove. The object need to delete manually.


Oct 14, 2009 at 10:19 AM

Thanks for reply!




protected override void OnRemoveItem(T item)
            ObjectInfo oi = ObjectInfo.GetInstance(typeof(T));
            if (!oi.IsNewObject(item))
                Type ot = owner.GetType();
                MemberHandler mh = oi.GetBelongsTo(ot);
                IBelongsTo o = mh.GetValue(item) as IBelongsTo;
                o.ForeignKey = CommonHelper.GetEmptyValue(o.ForeignKey.GetType());


Oct 14, 2009 at 11:26 AM

没有更新 m_UpdateColumns 是一个 bug,谢谢。

Oct 14, 2009 at 11:26 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.