First off I'm using .Net 3.5 SP1. I have a few entities related as follows.
An Engineer
has many Appointments
An Appointment
has many Engineers
A Timeslot
has many Appointments
I'm providing functionality in my data access layer to undo/discard changes made to entities. I'm doing this by calling...
ObjectContext.Refresh(RefreshMode.StoreWins, Entity entity);
This works fine for the entity itself and any 1 to Many relationships like the Timeslot
but doesn't revert any changes to the Many to Many relationships.
How woulld I go around reverting changes to Many to Many relationships preferably in a Generic manor as currently my DiscardChanges()
function is in a base class?
It is a bit convoluted, but this has worked for me to refresh M2M relations:
myengineer.Appointments.Clear();
context.AcceptAllChanges();
myengineer.Appointments.Load();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.