LINQ 到实体问题。自引用实体

发布于 2024-09-27 14:40:06 字数 240 浏览 2 评论 0原文

我有一个自引用实体(0 到 *)。 当我尝试删除一个时,出现错误。

数据结构为:

servise1
--服务1.1
--服务1.2
---服务1.2.1
---服务1.2.2
---服务1.2.3
--服务1.3
--服务1.4
服务2

等等...

我只需要删除其中一个服务及其所有子服务(级联)。

请帮我! )

I have a Self-referencing entity (0 to *).
When i tried to delete one, got an error.

The structure of data is:

servise1
--service 1.1
--service 1.2
---service 1.2.1
---service 1.2.2
---service 1.2.3
--service 1.3
--service 1.4
service 2

and so on...

I just need to delete one of the services with all subservices (cascade).

Please, help me! )

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只有影子陪我不离不弃 2024-10-04 14:40:06

如果您将删除级联添加到 sql 表定义中,请尝试将其更改回删除时无操作,然后转到实体模型,在设计器中选择关联,并在属性窗口中将删除设置为级联。

如果这仍然不起作用,那么您始终可以循环遍历所有子服务并在调用 savechanges 之前删除它们。

If you added the on delete cascade to the sql table definition try changing it back to on delete no action, then go to your entity model, select the association in the designer and set the delete to cascade in the properties window.

If that still doesn't work then you could always loop through all of the child services and delete them before calling savechanges.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文