Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6027381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:35:05+00:00 2026-05-23T04:35:05+00:00

Ok sorry for the long subject name… If I do the following: using (var

  • 0

Ok sorry for the long subject name…

If I do the following:

using (var transaction = session.BeginTransaction())
{
    // do something
    transaction.Commit();
}

If my do something caused an exception, would it auto rollback, or do I need to explicitly check for this like below:

using (var transaction = session.BeginTransaction())
{
    try
    {
        // do something
        transaction.Commit();
    }
    catch (Exception)
    {
        transaction.Rollback();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:35:06+00:00Added an answer on May 23, 2026 at 4:35 am

    It’s a safe assumption that the transaction will be rolled back if the commit fails in a using block.

    ITransaction wraps an ADO.NET transaction behind the scenes, so it depends on the provider specific implementation. The Dispose method in the source code I checked (2.1) assumes that calling Dispose on the internal IDbTransaction rolls it back.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just some background, sorry so long winded. I'm using the System.Data.SQLite ADO.net adapter to
(Sorry for long post) Ok guys, so I'm having some issues with something I'm
Long post - sorry.... I'm doing input validation for a WCF service and using
Sorry for this long question, it is flagged wiki since I'm asking for something
I'm still new in CSS, sorry for the long post. I have the following
Sorry for long winded post. I am trying to understand UIScrollView and running into
Sorry for the long question title. I guess I'm on to a loser on
Sorry for a long question and not a very descriptive title, but my problem
Sorry for this long post. The question is however small but requires full detail.
Sorry for the long explanation. Thanks in advance to all who are taking their

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.