StrataFrame Forum

Delete in a transaction?

http://forum.strataframe.net/Topic6532.aspx

By fparker - 2/2/2007

I have a form with three business objects on it.  They are configured such that two of them are children of the third.  The parent object is identified as the form's primary business object.  When the user clicks the delete button on the maintenance form toolstrip, I'd like the parent record and the both sets of child records to be deleted in a single transaction.  I overrode the form's delete method as follows:

public override void Delete(bool OnlyMarkAsDeleted, bool CheckSecurity)

{
 MicroFour.StrataFrame.Business.BusinessLayer.TransactionBegin("", IsolationLevel.ReadCommitted);

 foreach (BusinessLayer BO in this.BusinessObjects)
  if (BO != this.PrimaryBusinessObject)
   while (BO.Count > 0)
    {

      BO.MoveFirst();
      BO.DeleteCurrentRow(false);

    }

 this.PrimaryBusinessObject.DeleteCurrentRow(false);
 MicroFour.StrataFrame.Business.BusinessLayer.TransactionCommit("");

}

This code works fine except that the deletes are not really performed inside of a database transaction.  Is there a way to get StrataFrame to do what I want or should I write my own ADO code?  If I do write my own ADO code to do the deletes, how can I get the business objects to remove the rows in question from their in memory data tables?

Thanks for your help.

Fran Parker


By fparker - 2/7/2007

Any thoughts about this?  Thanks.

Fran

By StrataFrame Team - 2/8/2007

Your best bet would be to change the DeleteCurrentRow(false) to DeleteCurrentRow(true) which will only mark the records as deleted.  Then, call BusinessObject.Save(true); so that the business object will save the records on the transaction.