At the moment I'm looking for a way to find the old values of an entity in the [context].SubmitChanges().
As far as I can tell only the new values show up. Do I really need to do a query to the database to get the old values of the entity?
The solution by GertArnold:
public override void SubmitChanges(System.Data.Linq.ConflictMode failureMode)
{
// Get the changeset
ChangeSet changeSet = this.GetChangeSet();
// Put the updated objects into a IEnumerable
IEnumerable<object> updatedEntities = changeSet.Updates;
foreach (var entity in updatedEntities.Where(entity => AuditTypes.Contains(entity.GetType())))
{
var old = this.GetTable(entity.GetType()).GetModifiedMembers(entity);
// Do something with the old values
}
// Save the changes
base.SubmitChanges(failureMode);
}
Looks like you're looking for the Table.GetModifiedMembers method.
As you want old values of an entity, this method is useful.