I have a table with 3 columns: ID, Name, ParentID.
How can I delete a specific record with all its children (n levels deep)?
Using Entity Framework 3.5.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That the table is self referencing is application logic, it is not expressed in the SQL definition, and therefore is not understood by EF.
To delete these records through EF you need to write a routine that starts at the top and loads all the sub items. Then mark all these items as deleted, then call save changes.
To delete an item: