score:2
Yes, if you start a transaction that manipulates lots of records, and takes a long time to complete, then as a direct result competing operations will be blocked. This is especially true for "serializable" transactions, since they take the most locks (including key-range locks etc). This is the nature of a transaction; it is the I in ACID.
Options:
- don't do everything in one huge transaction
- have your read operations intentionally read past the locks (this is hugely double-edged - can be fine, but can cause big problems - treat with caution) - for example
NOLOCK
orREAD UNCOMMITTED
. - on full SQL server (not CE), try using snapshot isolation
score:1
using (var trans = new TransactionScope(
TransactionScopeOption.Required,
new TransactionOptions
{
IsolationLevel = IsolationLevel.ReadUncommitted
}
))
{
// Your LINQ to SQL query goes here where you read some data from DB
}
while updating tables (inserting, deleting or updating), they become locked, so if you want to read the data, which is not yet commit, so, you can use Transaction IsolationLevel.ReadUncommitted to allow dirty reads
score:0
Did you tried this ?
transactionOptions.Timeout = TransactionManager.MaximumTimeout;
Source: stackoverflow.com
Related Articles
- Transaction and TransactionScope isolation
- TransactionScope vs Transaction in LINQ to SQL
- LINQ Source Code Available
- .NET 4 Code Contracts: "requires unproven: source != null"
- creating Linq to sqlite dbml from DbLinq source code
- Can I prevent a LINQ DataContext from using a transaction when a TransactionScope is present?
- source code for LINQ 101 samples
- List or Array of String Contain specific word in Html Source Code
- c# Linq or code to extract groups from a single list of source data
- Convert string[] to int[] in one line of code using LINQ
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- Value cannot be null. Parameter name: source
- New transaction is not allowed because there are other threads running in the session LINQ To Entity
- Linq code to select one item
- C# - code to order by a property using the property name as a string
- How do I find the text within a div in the source of a web page using C#
- Roslyn failed to compile code
- Entity-framework code is slow when using Include() many times
- The data source does not support server-side data paging
- How are people unit testing code that uses Linq to SQL
- Entity Framework, Code First and Full Text Search
- What does this C# code with an "arrow" mean and how is it called?
- How to resolve Value cannot be null. Parameter name: source in linq?
- The source contains no DataRows
- Could not find an implementation of the query pattern for source type 'System.Data.Entity.DbSet'
- How to count the number of code lines in a C# solution, without comments and empty lines, and other redundant stuff, etc?
- Is there an IEnumerable implementation that only iterates over it's source (e.g. LINQ) once?
- Entity Framework 6 Code First Custom Functions
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- Is it possible to express this code in LINQ?
- C# Linq select/join with custom return type
- LINQ Query over heterogeneous collection of different types with same base class
- Getting the element missing in a second list of different type
- How do you transfer the execution of a Expression created by an IQueryable object to a IEnumerable?
- How to search for specific value in every field of Entity with complex types?
- Collection was modified; enumeration operation may not execute during select
- Using subquery value to filter parent result but still return all child items related to parent
- Check if object exists in the hierarchy using Entity Framework
- Most efficient way to group records alphabetically with LINQ
- Can't seem to use Linq with ASP.Net Navigation menu
- How to extract conditional statements from linq query?
- Optimizing away OrderBy() when using Any()
- EF / Linq query with JOIN and GROUP
- Display One record at a time in MVC through List
- Linq Include just one object from a one to many relation
- Using Select and Where in a List using LINQ statement
- Using linq to get nth word from each line in a list in C#
- Spatial Join in Entity Framework
- Using LINQ to delete an element from a ObservableCollection Source
- Is it possible to change & to & in the results from a LINQ query?