Community
Transactions -- Can you commit a Transaction within a Transaction without any problems?
I have one transaction that cycles through all objects in drawing..
I have another transaction that purges all purgable objects.
Can I call the Purge Function if I've already started a transaction?
What's the proper protocol here? Does that make sense?
'Purge Database Dim count As Integer = PurgeDatabase(DatabaseIn) Debug.Print("Number of Items Purged: " & count) 'Level 1 Start(Transaction/Drawing Database)----------------------------------------------- Using myTrans As Transaction = DatabaseIn.TransactionManager.StartTransaction 'Read Drawing Database 'Level 2 Block Table------------------------------------------------------------ Dim myBT As BlockTable = DatabaseIn.BlockTableId.GetObject(OpenMode.ForRead) 'Read BlockTable 'Loop Through All Objects For Each myObjID As ObjectId In myBT 'Changed this line of code from myModelSpace
Private Function PurgeDatabase(ByVal DB As Database) As Integer Debug.Assert(DB IsNot Nothing, "DB is nothing.") Dim idCount As Integer = 0 Dim tr As Transaction = DB.TransactionManager.StartTransaction Using tr 'Create the list of objects to "purge"
In general, yes. You can use nested transactions and commit the inner transaction first. If you abort any transaction it should also roll back the committed transactions nested within it. The full operation will only be committed once the topmost transaction has been commited.