TransactionScope and Npgsql - Prepared Transaction Issue

扶醉桌前 提交于 2019-12-11 01:38:42

问题


I have following code:

//...
using (TransactionScope tScope = new TransactionScope())
        {
            using (NpgsqlConnection myConnection = new NpgsqlConnection(_MyConnectionString))
            {
                try
                {
                    myConnection.Open();

                    //...

                    tScope.Complete();
                }
                catch (Exception ex)
                {
                    logger.Error(ex);
                }
                finally
                {
                    myConnection.Close();
                }
            }
        }
//...

The problem is, when some error occurred transactionscope do rollback, but, on the PostgreSQL server I have prepared transaction. And applications can not work anything with database server until I delete prepared transaction manualy.

Any solution?

BTW, I use Npgsql version: 2.0.11.91

Best regards

来源:https://stackoverflow.com/questions/7736693/transactionscope-and-npgsql-prepared-transaction-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!