📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

πŸ“š .NET Interview Questions

1325 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.

Transactions and Locking

ACID, lock modes and escalation, blocking and deadlocks, isolation levels, read committed snapshot and snapshot isolation, and optimistic and pessimistic concurrency.

  1. What are the SQL Server isolation levels? Explain read uncommitted, read committed, repeatable read and serializable, the anomalies each one prevents (dirty reads, non-repeatable reads, phantoms, lost updates), how each is implemented with locks, and how you choose one.

    The four locking isolation levels in SQL Server, the read anomalies each prevents, how S, X and key-range locks implement them, where snapshot-based levels fit, and how to choose and set the level from T-SQL and .NET.

    Mid-Level Theory Transactions and Locking Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  2. What is the blocked process report in SQL Server, how do you set it up on SQL Server and Azure SQL Database, and how do you read one?

    Capturing historical blocking with the blocked process threshold and the blocked_process_report Extended Events event, and reading the blocked and blocking process sections.

    Mid-Level Theory Transactions and Locking
  3. Every month-end your SQL Server logs a burst of deadlocks (error 1205) in the invoicing and payments code. How do you capture and read the deadlock graph from the system_health session, work out the cause, and fix it so it doesn't come back?

    Diagnosing SQL Server deadlocks: getting deadlock graphs from system_health (and Azure SQL), reading the victim, resources, owners and waiters, the common patterns (opposite lock order, conversion, missing index, serializable ranges), and fixing with lock order, indexes, RCSI, UPDLOCK and idempotent retries.

    Senior Debugging Transactions and Locking Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  4. Read committed snapshot (RCSI) vs snapshot isolation: how does row versioning work in SQL Server, what is the difference between statement-level and transaction-level consistency, what do the version store and update conflicts cost you, and what are the defaults on Azure SQL Database?

    Row versioning in SQL Server: RCSI vs snapshot isolation, statement vs transaction consistency, the tempdb or ADR persistent version store, update conflicts (error 3960), write skew, enabling them safely, and Azure SQL Database defaults.

    Mid-Level Theory Transactions and Locking Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  5. What does ACID mean? Explain atomicity, consistency, isolation and durability, and how SQL Server actually provides each one: the transaction log, write-ahead logging, locks and row versioning.

    ACID properties mapped to SQL Server mechanisms: the transaction log and write-ahead logging, rollback and recovery, constraints, locks and row versioning, and durability on commit.

    Junior Theory Transactions and Locking Β· πŸ”— 3 follow-ups
  6. How does locking work in SQL Server? Explain the main lock modes (shared, update, exclusive and the intent locks), lock granularity from row to table, which modes are compatible, and what lock escalation is and when it happens.

    SQL Server lock modes (S, U, X, IS, IX, SIX, Sch-S, Sch-M), the compatibility matrix, row, page and table granularity, the lock hierarchy, lock escalation thresholds and how to control it.

    Intermediate Theory Transactions and Locking Β· πŸ”— 3 follow-ups
  7. Users report that pages time out, and in SQL Server you see dozens of sessions waiting on LCK_M_ waits. How do you find the head blocker, work out what it is doing, and fix the cause? What usually causes blocking in a .NET application?

    Diagnosing SQL Server blocking: finding the head blocker with sys.dm_exec_requests, sp_WhoIsActive and the blocked process report, reading what it holds, and fixing the usual .NET causes (open transactions, missing indexes, escalation, chatty transactions).

    Mid-Level Debugging Transactions and Locking Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  8. Two users edit the same customer record, or two workers claim the same job. Show how you implement optimistic concurrency with rowversion and pessimistic concurrency with UPDLOCK/HOLDLOCK and sp_getapplock from .NET against SQL Server, and explain how you choose between them.

    Optimistic concurrency with a rowversion column and a WHERE check, pessimistic locking with UPDLOCK, HOLDLOCK and READPAST, application locks with sp_getapplock, implemented with Microsoft.Data.SqlClient and Dapper, and the criteria for choosing each.

    Mid-Level Coding Transactions and Locking Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  9. You sell limited stock (or book seats, rooms or appointments) and under load you oversell. Write the T-SQL that prevents overselling and double booking: an atomic conditional UPDATE, a unique constraint for seat or slot booking, and serializable range locking for overlapping bookings. When do you use each?

    Preventing overselling and double booking in SQL Server: atomic conditional UPDATE with @@ROWCOUNT, CHECK constraints, unique constraints and filtered unique indexes for slots, serializable or UPDLOCK/HOLDLOCK range checks for overlapping intervals, and idempotent retries from .NET.

    Senior Sql Transactions and Locking Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  10. How do you manage SQL Server transactions from .NET? Compare SqlTransaction and TransactionScope, explain when TransactionScope escalates to a distributed transaction, how async flow works, how pooled connections can leak open transactions or isolation levels, and why SET XACT_ABORT ON matters.

    Transactions from .NET against SQL Server: SqlTransaction vs TransactionScope (default serializable, TransactionScopeAsyncFlowOption, escalation to distributed transactions), connection pooling and leaked transactions, isolation level reset, timeouts, and XACT_ABORT.

    Senior Theory Transactions and Locking Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me