PreparingEnlistment.ForceRollback Méthode

Définition

Indique que la transaction doit être restaurée.

Surcharges

ForceRollback()

Indique que la transaction doit être restaurée.

ForceRollback(Exception)

Indique que la transaction doit être restaurée.

ForceRollback()

Indique que la transaction doit être restaurée.

C#
public void ForceRollback ();

Exemples

C#
class myEnlistmentClass : IEnlistmentNotification
{
    public void Prepare(PreparingEnlistment preparingEnlistment)
    {
        Console.WriteLine("Prepare notification received");

        //Perform transactional work

        //If work finished correctly, reply prepared
        preparingEnlistment.Prepared();

        // otherwise, do a ForceRollback
        preparingEnlistment.ForceRollback();
    }

    public void Commit(Enlistment enlistment)
    {
        Console.WriteLine("Commit notification received");

        //Do any work necessary when commit notification is received

        //Declare done on the enlistment
        enlistment.Done();
    }

    public void Rollback(Enlistment enlistment)
    {
        Console.WriteLine("Rollback notification received");

        //Do any work necessary when rollback notification is received

        //Declare done on the enlistment
        enlistment.Done();
    }

    public void InDoubt(Enlistment enlistment)
    {
        Console.WriteLine("In doubt notification received");

        //Do any work necessary when indout notification is received
        
        //Declare done on the enlistment
        enlistment.Done();
    }
}

Remarques

Une implémentation de la méthode de l’interface Prepare IEnlistmentNotification appelle cette méthode pour indiquer que la transaction doit être annulée.

S’applique à

.NET 7 et autres versions
Produit Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Standard 2.0, 2.1

ForceRollback(Exception)

Indique que la transaction doit être restaurée.

C#
public void ForceRollback (Exception? e);
C#
public void ForceRollback (Exception e);
C#
public void ForceRollback (Exception ex);

Paramètres

eex
Exception

Explication sur la raison pour laquelle une restauration est déclenchée.

S’applique à

.NET 7 et autres versions
Produit Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Standard 2.0, 2.1