Linq to sql - delete some related records

I use linq for sql and I have many tables with foreign keys leading to UserId.

Is it possible to clear some of these external tables when deleting.

For example, I want the user profile (another table) to be deleted automatically with the user, but not with messages from forum users.

Is this possible, or do I need to handle this with code?

+5
source share
2 answers

I think the link is very useful.

LINQ to SQL does not support or recognize cascading delete operations. If you want to delete a row in a table that has restrictions on this, you must perform one of the following Tasks:

  • ON DELETE CASCADE .

  • , .

+12

, Cascade on Delete SQL?

0

All Articles