How to delete all records in a BO?


Author
Message
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi,

I have a a BO with related records and at some point I would like to delete all records in the BO pretty much like a VFP DELETE ALL or ZAP, how to do this?

I have tried using the BO's GetEnumerable() I saw in thread like this:

For Each bo As IBS_BOL.PaymentScheduleBO In Me.PaymentScheduleBO1.GetEnumerable()

     bo.DeleteCurrentRow(True)

Next

Me.PaymentScheduleBO1.Save()

But the above code is not deleting all rows in the BO, so I must be missing something here.

Edhy Rijo

Replies
Richard Keller
Richard Keller
StrataFrame User (174 reputation)StrataFrame User (174 reputation)StrataFrame User (174 reputation)StrataFrame User (174 reputation)StrataFrame User (174 reputation)StrataFrame User (174 reputation)StrataFrame User (174 reputation)StrataFrame User (174 reputation)StrataFrame User (174 reputation)
Group: Forum Members
Posts: 84, Visits: 324
Be careful with using Truncate.  It is handled differently in Log Operations.   If the table has a FOREIGN KEY constraint you cannot use truncate.  In addition, no Triggers will be fired as it is a non-logged operation.   I generally frown on the use of Truncate in any operational code for those two reasons.

Richard

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
We never use TRUNCATE in code either...except when the table truly needs to be cleared out and reset, and which time the code should accomodate this.  The context of this post is more in regards to the replacement method of ZAP in FoxPro for a similar method in SQL Server.  This would be the method in this case.
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Thanks to all for the posting.

I decided to use the following code in this particular case...

Dim lnCount As Integer = Me.PaymentScheduleBO1.Count

For I = 0 To lnCount - 1

     Me.PaymentScheduleBO1.DeleteCurrentRow(True)

Next

Me.PaymentScheduleBO1.Save()

This is very fast and will only do one trip to the database to remove all deleted records.

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
That is a good solution.  You could also just do a while as well:

Do While MyBo.Count > 0
     MyBo.DeleteCurrentRow(True)
End Do

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Thanks you Trent,

I am learning a lot every day. 

So far this project is coming out pretty good, and I fall in love with the new Enhanced ListView, those enhancements are really a time saver for developers and I am glad you incorporated them.   w00t

If possible please, let me know when will be the next beta release that will include the added property to handle the delete flag.

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Yeah, I plan on posting a new build soon...but I have the DDT torn up a little bit right now, so I need to get "Humpty Dumpty" put back together again before I post a new build Smile.  I am using it every day so it isn't necessarily the functionality, but rather the UI.  The DDT is getting a face lift that will continue over the next several updates so that we can incorporate some new functionality that we have planned.
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Thanks for the info.

No rush on my part, so far I am using my temporary fix, so I can live with it until the next release. Tongue

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Edhy Rijo - 18 Years Ago
Keith Chisarik - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Edhy Rijo - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Keith Chisarik - 18 Years Ago
Richard Keller - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Edhy Rijo - 18 Years Ago
Trent L. Taylor - 18 Years Ago
                         Thanks you Trent, I am learning a lot every day. So far this...
Edhy Rijo - 18 Years Ago
                             Yeah, I plan on posting a new build soon...but I have the DDT torn up...
Trent L. Taylor - 18 Years Ago
                                 Thanks for the info. No rush on my part, so far I am using my...
Edhy Rijo - 18 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search