Cascade on delete using unidirectional Many-To-Many mapping

非 Y 不嫁゛ 提交于 2019-12-06 00:23:57

If B doesn't reference A then it doesn't know about the mapping table so it can't cascade the delete. As I see it you have two options:

  1. Cascade the delete in the database using cascading deletes on your FK or a trigger.
  2. Map the relationship from B to A; you don't have to expose it to consumers of your class, the A collection could be mapped as a private field using an access strategy. I always do this for collections (using .Access.CamelCaseField(Prefix.Underscore)) so that I don't expose IList.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!