为什么,在PLINQO中,以下是有效的;
parent.ManyToManyChildList.Add(child)
context.SubmitChanges();但是下面的不是吗?
parent.ManyTomanyChildList.Remove(child)
context.SumbmitChanges();使用Remove(),尝试将多对多表的PK的父FK部分设置为null。这是使用PLINQO删除关系的唯一方法吗?
context.ManyToManyEntity.DeleteOnSubmit(entity)
context.SubmitChanges();发布于 2011-04-28 13:32:38
打开.DBML (在xml编辑器中)并在外键的父表的多对多表的父端上将外键association.DeleteOnNull=设置为“true”解决了这个问题。
<Table Name="dbo.ParentChild" Member="ParentChild">
<Type Name="ParentChild">
<Column Name="ParentId" Storage="_parentId" Type="System.Int32" DbType="int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
<Column Name="ChildId" Storage="_childId" Type="System.Int32" DbType="int NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
<Association Name="Child_ParentChild" Member="Child" Storage="_child" ThisKey="ChildId" Type="Child" IsForeignKey="true" DeleteOnNull="false" />
<Association Name="Parent_ParentChild" Member="Parent" Storage="_parent" ThisKey="ParentId" Type="Parent" IsForeignKey="true" DeleteOnNull="true" />
</Type>
</Table>这里对此进行了解释;http://blogs.msdn.com/b/bethmassi/archive/2007/10/02/linq-to-sql-and-one-to-many-relationships.aspx
https://stackoverflow.com/questions/5813304
复制相似问题