I am trying to remove an object from a collection in essence, but unfortunately my code is not working. I would appreciate it if you could take a look and let me know if you can understand what I'm doing wrong. My objects are as follows:
- Sign Person (many-to-many relationship)
- β BadgeRequirement icon (one-to-many relationship)
- Face contains ICollection of icons.
- Icon contains user ICollection
- BadgeRequirement contains a Foreign Key icon
Adding and editing entries works absolutely fine.
However, when I try to remove the Icon from the Person using the code below, it does not work:
Postback event handler on example.aspx ****The person object has been loaded as part of the load event on the page**** Badge badge = BadgeHelper.getBadge(badgeID); if (command == "Delete") { PersonHelper.removeBadgeFromPerson(badge, person); } Delete method on PersonHelper class (wrapper for all processing) person.Badges.Remove(badge); DbContext.SaveChanges();
Remove (badge) returns false and I cannot profile it since I am using SQL Compact 4.0
Thanks in advance for your help!
Chris
source share