“在一组变化中检测到一个循环”当尝试向数据库添加循环链表时
我正在使用“数据库内”循环链表(cll)。我使用 Linq to Sql 插入形成这些 cll 的数据库条目。
它们具有一般形式:
id uuid | nextId uuid | current bit
如果我尝试使用形成完整 cll 的几个对象执行 SubmitChanges,我会收到错误“在更改集中检测到循环”。
我可以通过在单独的 SubmitChanges 中使链接列表“循环”来规避此问题,但这有两个缺点:我失去了在一个事务中执行此操作的能力。在一小段时间内,我的数据库中的数据不正确。
有办法解决这种行为吗?
I'm using a 'in database' circularly linked list (cll). I'm inserting the database entries forming these cll's using Linq to Sql.
They have the general form:
id uuid | nextId uuid | current bit
If i try to do a SubmitChanges with a few objects forming a complete cll, i get the error "A cycle was detected in the set of changes".
I can circumvent this by making the linked list 'circular' in a separate SubmitChanges, but this has two down sides: I'm losing my capability to do this in one transaction. For a small period the data in my database isn't correct.
Is there a way to fix this behaviour?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数据库需要强制执行其约束,我想您在
nextId
和Id
之间有一个外键约束。如果这条关系链回到起点(正如您所发现的),数据库将不允许这样做。我怀疑您的选择是:
即使您的第二个选项也不起作用,因为数据库不允许您添加最后一个引用。
The database needs to enforce its contraints, and I imagine you have a foreign key constraint between
nextId
andId
. If this chain of relations leads back to the start (as you have found) the database will not allow it.I suspect your choices are:
Even your second option won't work, as the DB won't allow you to add this last reference.