SubTransaction Class

Sub-transactions are objects that provide control over a subset of changes in a document.
Inheritance Hierarchy
SystemObject
  Autodesk.Revit.DBSubTransaction

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public class SubTransaction : IDisposable

The SubTransaction type exposes the following members.

Constructors
 NameDescription
Public methodSubTransaction Instantiates a sub-transaction object
Top
Properties
 NameDescription
Public propertyIsValidObject Specifies whether the .NET object represents a valid Revit entity.
Top
Methods
 NameDescription
Public methodCommit Commits all changes made to the model made during the sub-transaction.
Public methodDisposeReleases all resources used by the SubTransaction
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetStatus Returns the current status of the sub-transaction.
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodHasEnded Determines whether the sub-transaction has ended already.
Public methodHasStarted Determines whether the sub-transaction has been started yet.
Public methodRollBack Discards all changes made to the model during the sub-transaction.
Public methodStart Starts the sub-transaction.
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Remarks
A Sub-transaction can only be active as a part of an open transaction. Sub-transactions may be nested inside each other, but with the restriction that every nested sub-transaction is entirely contained (opened and closed) in the parent sub-transaction.

If a sub-transaction was started and not committed or rolled back by the time the SubTransaction object is about to be disposed, the destructor will roll back the sub-transaction automatically, thus all changes made to the document during the sub-transaction will be discarded. It is not recommended to rely on this default behavior though. Instead, it is advised to always call either Commit or RollBack explicitly before the sub-transaction object gets disposed. Please note that unless invoked explicitly the actual destruction of an object in managed code might not happen until the object is collected by the garbage collector.

See Also