A
Andrus
I'm creating DbLinq MDI WinForms application.
It allows edit customers list in DataGridView. Every row change is submitted
separately.
As Nicholas recommends, it is reasonable to create database Context object
Db in form constructor and keep it alive in form existence.
I use following command to delete row when user selects delete row command:
Db.Customers.Remove( customer );
try {
Db.SubmitChanges();
} catch (Exception ex) {
// Error => we MUST roll back modifications
UIManager.Error(ex, "Cannot delete a row");
}
In case of delete error (e.q foreign key violation) I need to rollback the
delete operation in Db.
Any idea how to do this ?
Currently deleted customer remains in Db. Invalid delete keeps submitted in
every SubmitChanges() making any future SubmitChanges() impossible.
Andrus.
It allows edit customers list in DataGridView. Every row change is submitted
separately.
As Nicholas recommends, it is reasonable to create database Context object
Db in form constructor and keep it alive in form existence.
I use following command to delete row when user selects delete row command:
Db.Customers.Remove( customer );
try {
Db.SubmitChanges();
} catch (Exception ex) {
// Error => we MUST roll back modifications
UIManager.Error(ex, "Cannot delete a row");
}
In case of delete error (e.q foreign key violation) I need to rollback the
delete operation in Db.
Any idea how to do this ?
Currently deleted customer remains in Db. Invalid delete keeps submitted in
every SubmitChanges() making any future SubmitChanges() impossible.
Andrus.