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
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

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 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
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 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
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.
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
You can't change the contents of an enumeration...that is just .NET.  The reason you don't flat out get an exception when using the GetEnumerable is because the GetEnumerable returns unique instances of the BO...so even though you are changing the collection it is somewhat wrapped...but you will never get the records deleted.  But you can delete a lot of different ways, create an array of the PKs to delete and then enumerate that collection, create a shared method to delete for you, etc.  At some point we may add another overload to the BO that allows you to pass a "WhereClause" like the Seek method for a delete.  But for now those are some options.
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
Trent, Keith,

Thanks for the recommendations, I am sure will use them.

In this case I am dealing with a few records, less than 12, and since I already have a BO with those 12 records shown on a list, I was looking for an easy way to get rid of those 12 records in a single step. 

I could implement any of your suggestions by creating a method in the BO to delete those records using the Forein key of the parent, but wanted to know if there was a better way to handle this.

Edhy Rijo

Keith Chisarik
Keith Chisarik
StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
Great to know about TRUNCATE. Thanks.

Keith Chisarik
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search