Reputation: 3143
What should the code below do? What is the purpose of adding the included table in this code, should it do a cascaded delete of the JobType related to the PersonId or will it only delete the Person with the specified PersonId ?
db.tblPerson.Remove(db.tblPerson.Include("tblJobType").FirstOrDefault(c => c.PersonId== PersonId));
Upvotes: 3
Views: 36
Reputation: 6844
In this instance the .Include is either superfluous or really bad design.
Superfluous:
Bad Design:
Conclusion
The code posted is simply removing the Person with the specified PersonId. The .Include is likely just a copy-paste error that has no effect here. As noted above, this will not cause a CascadeDelete, that is determined by a different setting. However, you should be aware of the side-effects of .Include.
Upvotes: 2