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

  • Home
  • SEARCH
  • 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 9157073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:55:26+00:00 2026-06-17T12:55:26+00:00

Trying to understand isolation levels better – using entity framework and sql server What

  • 0

Trying to understand isolation levels better – using entity framework and sql server

What would be the recommended isolation level for the following scenario –

An online booking system say for flight tickets or event tickets

Scenario –

Let us assume the capacity of the event is 100 – the pseudocode is as follows

   Begin transaction
   If SeatCount < 100 
   SeatCount  = SeatCount + 1
   End transaction

EDIT – in response to the comment here is how my pseudeocode would look like in actual code. I don’t have the code and I am just looking to understand the scenario better. Let us say you have two tables “event” where you have two columns – “name, seatsbooked” and a table tickets where you have the individual ticket details.

         bool tSuccess = false;
        //this transactionscope resolves to serializable 
        using (TransactionScope transaction = new TransactionScope()            
        {                
            try{
            if(objectcontext.event.SeatsBooked < 100)
            {
                objectcontext.event.SeatsBooked = objectcontext.event.SeatsBooked + 1;
                ticket newTicket = new ticket{
                };
                objectcontext.tickets.AddObject(newTicket);
                objectcontext.SaveChanges();
            }
           }
           catch(Exception e)
           {
              //log and return 
           }
        }
        if (tSuccess)
        {
            bd.AcceptAllChanges();
        }

In this scenario is it ok to assume that read committed or repeatable read would result in overbooking or lost updates since two transactions can compete for the same seat.

Is the recommended approach to go with serializable?

  • 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-06-17T12:55:28+00:00Added an answer on June 17, 2026 at 12:55 pm

    Repeatable read is required, serializable is not necessary. Repeatable read ensures that the update will see the same seat count as the previous select did.

    Your TransactionScope needs to span the entire logical unit of work, though. Not just the write.

    In raw SQL it would be more elegant to use WITH (UPDLOCK, HOLDLOCK) but that is not available with EF.

    In case of a conflict, a deadlock will easily occur. Either retry the entire logical transaction or select with UPDLOCK. UPDLOCK will avoid that deadlock entirely.

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

Sidebar

Related Questions

I am trying to understand isolation/locks in SQL Server. I have following scenario in
Trying to completely understand SQL Server Isolation Levels - notably REPEATABLE READ. I have
I am trying to understand isolation levels of Spring transactions. Here is the example
Trying to understand what Sql Profiler means by emitting sp_reset_connection. I have the following,
I am trying to identify the reason of deadlock using SQL Server Profiler. Here's
Trying to understand Ruby a bit better, I ran into this code surfing the
Trying to understand something. I created a d:\svn\repository on my server. I committed folders
Trying to understand why this doesn't work. I keep getting the following errors: left
Trying to understand resources in java-land. I believe the following is true: Resources loaded
I am trying to understand how range.cover? works and following seems confusing - (as..at).cover?(ass)

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.