views:

55

answers:

2

Hi I am using (evaluating :)) Subsonic ActiveRecord mode for accessing sqLite. Need transaction to work. Regular stuff... Of ocurse!

Following snippet explains the desired logic. I couldn't find the right example in docs.

        using (TransactionScope ts = new TransactionScope())
        {
            using (SharedDbConnectionScope sharedConnectionScope = new SharedDbConnectionScope())
            {
                // insert data in table 1 with primary key column. Save the id returned for later use.

                // insert data in table 2 with a foreign key column. Use the Id generated in table 1.

                // ts.commit here

            }
        }

Please advise. Thanks

A: 

Here is what I was looking for.

       using (var ts = new TransactionScope())
        {
            using (SharedDbConnectionScope scope = new SharedDbConnectionScope())
            {
                try
                {
                    document.Save();
                    documentsDatum.DocumentId = document.Id;
                    documentsDatum.Save();

                    ts.Complete();

                }
                catch (Exception ex )
                {

                    throw new Exception("trx failed " + ex.Message, ex);
                }
            }
        }
AJ