private void RowUpdatingHandler (object sender, SqlRowUpdatingEventArgs e)
{
if (e.Status != UpdateStatus.Continue)
return;
switch (e.StatementType) {
case StatementType.Delete:
deleteCommand = e.Command;
break;
case StatementType.Insert:
insertCommand = e.Command;
break;
case StatementType.Update:
updateCommand = e.Command;
break;
default:
return;
}
try {
BuildCache (false);
switch (e.StatementType) {
case StatementType.Delete:
e.Command = CreateDeleteCommand (e.Row, e.TableMapping);
e.Status = UpdateStatus.Continue;
break;
case StatementType.Insert:
e.Command = CreateInsertCommand (e.Row, e.TableMapping);
e.Status = UpdateStatus.Continue;
break;
case StatementType.Update:
e.Command = CreateUpdateCommand (e.Row, e.TableMapping);
e.Status = UpdateStatus.Continue;
break;
}
if (e.Command != null && e.Row != null) {
e.Row.AcceptChanges ();
e.Status = UpdateStatus.SkipCurrentRow;
}
}
catch (Exception exception) {
e.Errors = exception;
e.Status = UpdateStatus.ErrorsOccurred;
}
}