Last active
June 5, 2018 14:05
-
-
Save PilotBob/300adc78d28b6ae2f6eb1cf7e7559240 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This works: | |
db.Entry(target).Collection(r => r.Permissions).Load(); | |
target.Permissions.Remove(permission); | |
This doesn't: | |
db.Entry(target).Collection(r => r.Permissions).Query().Where(p => p.ID == permission.ID).Load(); | |
target.Permissions.Remove(permission); | |
In the latter case.. the Load does not load the collection with the matching record. In that case, when I call SaveChanges | |
after the remove, the child record isn't deleted. In the first case, load does load the collection, of course it loads | |
ALL the child records, the remove does remove the single record and delete it from the db when SaveChanges is called. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment