linq-to-sqlcascadeentityset

Remove data from linq relation


If i have a sq-table relation model that looks like this:

Project <----> ProjectActivity <----> Activity

Where Project and Activity has many to many connections via ProjectActivity and i want to remove a ProjectActivity (not just set its Projekt FK to null). How to i do this?

If I on the EntitySet takes Project.ProjectActivities.Clear(); the relation will be deletet but the ProjectActivity row will still be there with null reference to Project.


Solution

  • dataContext.ProjectActivities.DeleteAllOnSubmit(Project.ProjectActivities); 
    

    that should work, you have to delete them not just clear relations