Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DeleteAll() Method on Business Objects
Message
From
28/08/2006 18:20:40
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
DeleteAll() Method on Business Objects
Miscellaneous
Thread ID:
01149204
Message ID:
01149204
Views:
63
Hi Kevin

I have a curiousity question. I have been working with the DeleteAll() method recently and have noticed the following.

In the mmBusinessObject.DeleteAll(tableName) method (see excert below) there is a for loop that processes each row to be delete calling the mmBusinessObject.Delete(dataRow). After the for loop has been processed the bizobj checks the ImmediateDelete flag to see if the SaveDataset methos should be called.
for (int Row = 0; DeleteRow < RowCount; Row++)
				{
					// Check if the row is already deleted
					if (dt.Rows[DeleteRow].RowState != DataRowState.Deleted &&
						dt.Rows[DeleteRow].RowState != DataRowState.Detached) 
					{
						// Delete the row
						this.Delete(dt.Rows[DeleteRow]);

						// Get an updated row count since this may change
						// if ImmediateDelete is true, or if deleting a
						// newly added record (both of these conditions
						// remove the DataRow from the DataTable
						RowCount = dt.Rows.Count;
					}
					else
					{
						// Increment the variable so we go to the next row
						DeleteRow++;
					}
				}

				// If specified to do so, save the DataSet which deletes
				// all rows marked as Deleted from the database
				if (this.ImmediateDelete)
				{
					this.SaveDataSet(ds, tableName);
				}
However, inside the Delete(dataRow), this also performs a check on ImmediateDelete property (see below)
if (dr.RowState != DataRowState.Added && this.ImmediateDelete)
				{
					// Retrieve the row being deleted into a temporary DataSet
					// (we're using GetConflictData() to do this)
					DataSet dsDelete = this.GetConflictData(dr);

					// Delete the row from the temporary DataSet and save it
					dsDelete.Tables[TableName].Rows[0].Delete();
					mmDataAccessBase dao = this.GetDataAccessObject();
					dao.SaveDataSet(dsDelete, TableName, null, false, null);

					// Remove the row from the original DataSet
					ds.Tables[TableName].Rows.Remove(dr);
				}
				else
				{
					// Just mark the row as deleted
					dr.Delete();
				}
If the Delete(dataRow) method checks the ImmediateDeledte property and if true, executes the SaveDataset, then the subsequent check back in the DeleteAll() method will never have any data to save? Is this correct?

Are we suffering any performance penaltys by executing the SaveDataset() method when deleting each individual row, as opposed to executing the SaveDataset once as it is in the DeleteAll() method?

Get all that?? <s>.

I'll be interested to hear your comments.

Regards
Darren
Next
Reply
Map
View

Click here to load this message in the networking platform