views:

341

answers:

1

Hi

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?

A: 

It is a bit convoluted, but this has worked for me to refresh M2M relations:

myengineer.Appointments.Clear();
context.AcceptAllChanges();
myengineer.Appointments.Load();
Marcanpilami