Cascade delete on many-to-many between same table

 ̄綄美尐妖づ 提交于 2019-12-04 04:16:05

I came across a similar problem myself....I ended up removing the foreign key. Cyclic deletion logic was pushed to Code.

I had a similar problem with a treeview. This is a code to delete that was useful to me: (I save the id into the value property and I'm using a entity model framwork to delete) Maybe can help someone

private void removeRecursive(TreeNode parentToDelete)
    {
        foreach (TreeNode tn in parentToDelete.ChildNodes)
            removeRecursive(tn);

        long id = long.Parse(parentToDelete.Value);
        Category deleteCat = context.Categories.Single(x => x.Id ==id);
        context.Categories.DeleteObject(deleteCat);
    }

PD sorry about my english it's awful...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!