开发者

Entity transaction not working

开发者 https://www.devze.com 2023-02-09 01:26 出处:网络
I am using entity transaction in my project but somehow it is not working. It is also not giving any error. Pls help me.

I am using entity transaction in my project but somehow it is not working. It is also not giving any error. Pls help me. I am giving some code ...

EntityConnection objEntityCon = new EntityConnection(CommonDividentBL.GetEntityConnectionString());
    objEntityCon.Open();
    // Begin Transaction
    EntityTransaction entityTransaction = objEntityCon.BeginTransaction();
    try
    {
  开发者_Python百科      //database saving code

        entityTransaction.Commit();
        objEntityCon.Close();
    }
    catch (Exception ex)
    {
        entityTransaction.Rollback();
    }


Are you sure that it doesn't have any error? Tried in the debugger?

Your code catches any exceptions, rolls back your changes but does not notify you of the exception (eg by re-throwing or logging or etc)

0

精彩评论

暂无评论...
验证码 换一张
取 消