Transaction Class
TOC
Collapse the table of content
Expand the table of content

Transaction Class

 

A transaction makes sure that changes that were made to the store are treated as a group that can be committed or rolled back.

Namespace:   Microsoft.VisualStudio.Modeling
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.12.0.dll)

System.Object
  System.MarshalByRefObject
    Microsoft.VisualStudio.Modeling.Transaction

public class Transaction : MarshalByRefObject, IDisposable

NameDescription
System_CAPS_pubpropertyContext

Gets the transaction and enables clients to append user data to the transaction.

System_CAPS_pubpropertyContextInstance

Gets the Context for this transaction.

System_CAPS_pubpropertyForceAllRulesToCommitTime

Gets or sets a flag that forces all nested rules to occur at LocalCommit time for the current transaction.

System_CAPS_pubpropertyHasPendingChanges

Gets the transaction and verifies whether changes to the store have been made during this transaction.

System_CAPS_pubpropertyHaveCommitTimeRulesFired

Indicates whether the commit time rules have been fired or not

System_CAPS_pubpropertyId

Gets the ID for this transaction.

System_CAPS_pubpropertyInRollback

Gets the transaction and verifies whether this transaction is being rolled back.

System_CAPS_pubpropertyIsActive

Gets the transaction and verifies whether this transaction is processing.

System_CAPS_pubpropertyIsHidden

Gets the transaction and verifies whether the transaction is hidden.

System_CAPS_pubpropertyIsNested

Gets the transaction and verifies whether a transaction is nested within another transaction.

System_CAPS_pubpropertyIsSerializing

Gets the transaction and verifies whether the transaction is currently serializing.

System_CAPS_pubpropertyName

Gets or sets the name of the transaction.

System_CAPS_pubpropertyParent

Gets the top-level transaction that is assigned to the nested transaction.

System_CAPS_pubpropertyPartitionStates

Gets information about the state of all partitions in the store.

System_CAPS_pubpropertySequenceNumber

Gets the sequence number for the transaction.

System_CAPS_pubpropertyStore

Gets the store to which the transaction belongs.

System_CAPS_pubpropertyTopLevelTransaction

Gets the top-level transaction of the transaction hierarchy.

System_CAPS_pubpropertyTransactionDepth

Gets the number of transactions in which this transaction is nested.

NameDescription
System_CAPS_pubmethodCommit()

Commits the transaction.

System_CAPS_pubmethodCreateObjRef(Type)

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodDispose()

Disposes the state of the transaction.

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_protmethodFinalize()

Finalizes the transaction.(Overrides Object.Finalize().)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetLifetimeService()

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

(Inherited from MarshalByRefObject.)

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone(Boolean)

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodRollback()

The Store will be set back to the state that it was in when the transaction was created.

System_CAPS_pubmethodToString()

(Inherited from Object.)

NameDescription
System_CAPS_pubmethodGetSerializationContext()

Get the SerializationContext active in the context of the specified transaction. The SerializationContext is stored in the TranactionContext of serializing transactions. If the transaction is nested the transaction stack is searched to find the nearest enclosing serialization transaction with a SerializationContext.(Defined by SerializationContextTransactionExtensions.)

A transaction enables you to group changes. It also keeps track of the actions that are performed in a transaction so that they can be undone at a later stage.

Changes to the store must be done in a transaction. Changes to the store are made only if the transaction commits. A transaction can have the store accept the changes when the local transaction is committed or when the top-level transaction is committed. Local transactions are nested in a top-level transaction. A nested transaction must commit or roll back before the next top-level transaction can commit or roll back. For more information, see the example for the TransactionDepth property.

A transaction also keeps track of the actions that have occurred. This enables a group of actions to be undone or redone at a later stage with the UndoManager property.

A transaction should be disposed. This can be done by using the Dispose method or by creating the transaction in a Using construct. If the transaction has not been committed when it is disposed, the transaction is automatically rolled back and any changes are canceled.

The following example shows a transaction that modifies the store. The transaction is committed. If the transaction is rolled back, any changes to the store are canceled. The transaction is disposed automatically at the end of the using block.

using (Transaction txCreateElem =  model.Store.TransactionManager.BeginTransaction("Create named element")
{
  A a = new A(store);
  a.Name = "Fred";
  // Commit the transaction and add the named element to the model
  txCreateElem.Commit();
}

For examples and more information, see .0bee4373-5205-4566-85ac-8747dfe27a78

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft