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

📚 Interview question

How would you make a set of split queries read a consistent snapshot of the data on SQL Server?

Mid-Level Theory Intermediate

🎯 Key points

  • Split queries are separate statements; without a transaction they can see different data
  • BeginTransactionAsync(IsolationLevel.Snapshot) gives a point-in-time read without blocking writers
  • Requires ALLOW_SNAPSHOT_ISOLATION ON; Azure SQL has it on by default
  • Row versioning costs version store space (tempdb, or the user database with ADR) and write overhead
  • Serializable works but takes range locks and blocks writers
  • Keep the transaction short; monitor version store size
  • A single projected query is consistent by itself, when one query can return the shape

⏱ 30-second answer

Wrap the split query in a transaction: await using var tx = await db.Database.BeginTransactionAsync(IsolationLevel.Snapshot, ct); then run the query and commit. Every split statement then reads the same committed row versions without blocking writers. Snapshot isolation must be allowed on the database (ALTER DATABASE ... SET ALLOW_SNAPSHOT_ISOLATION ON; Azure SQL enables it by default); turning it on adds row versioning for all writes, so test the tempdb / version store impact. Serializable also gives consistency but takes range locks and blocks writers. Keep the transaction short. If a single projected query can return what you need, it is consistent by itself and avoids the problem.

🔍 What the interviewer is checking

Checks they can combine split queries with a transaction and the right isolation level, and know the cost

↩ Usually asked after

More in EF Core Performance

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me