If I use the option TransactionScope.Suppress in a nested transactionscope at
present the provider seems to ignore this option and will not insert the
first statement - an example.

var connection1 = new FbConnection(@"initial catalog=DB1.FDB;user
id=username;password=pwrd;Enlist=true;");
var connection2 = new FbConnection(@"initial catalog=DB2.FDB;user
id=username;password=pwrd;Enlist=true;");

using (TransactionScope scope1 = new TransactionScope())
{
    connection1.Open();
    connection2.Open();

    try
    {
        //Start of non-transactional section 
        using (TransactionScope scope2 = new
TransactionScope(TransactionScopeOption.Suppress))
        {
            // This should be inserted even though the INSERT's following it
in scope1 throws an exception
            using (var command = connection1.CreateCommand())
            {
                command.CommandText = "INSERT INTO TABLE1(Name)
VALUES('Should insert - not in transaction scope');";
                command.ExecuteNonQuery();
            }
        }
    }
    catch
    {
    }
    
    //Rest of scope1
    using (var command = connection1.CreateCommand())
    {
        command.CommandText = "INSERT INTO TABLE1(Name) VALUES('this insert
does not throw an exception');";
        command.ExecuteNonQuery();
    }

    // This should fail
    using (var command = connection2.CreateCommand())
    {
        command.CommandText = "INSERT INTO TABLE2(AFIELD) VALUES('this
insert throws an exception');";
        command.ExecuteNonQuery();
    }

    scope1.Complete();
}


My understanding is that the first INSERT statement should be inserted, and
the second two statements should not be inserted.  However at present NONE
of the statements are being inserted.

What do I have setup wrong or is this a bug.

Thanks
Gareth
-- 
View this message in context: 
http://firebird.1100200.n4.nabble.com/TransactionScope-suppress-seems-not-to-work-tp2540252p2540252.html
Sent from the firebird-net-provider mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to