Is it possible to write a select statement that also has NOLOCK and TOP in LINQ?
What about setting RowCount before the query?
From stackoverflow
-
Adding .Take(5) to your query is the same as Top 5
Adding .Skip(5) will start returning results on row 6
Not sure how you would add a NOLOCK to a query.
-
Here's a good article dealing with
TransactionScope: -
TGnat notes how to do
TOP(via.Take(n)). However, there is no inbuilt way of adding granular hints (etc) like(NOLOCK)to specific tables. There are a few ways of getting around this:- write a stored procedure and expose it via the data-context
- write a udf and expose it via the data-context
- use
ExecuteQuerywith (parameterized) TSQL that has aNOLOCK
Of the 3, the UDF would get my vote:
- it doesn't leave you with literal queries in the C#
- the metadata is strongly defined
- it is composable (with
.Skip/.Take/.Whereetc)
Lucas : 4th option: settings the isolation level to "read uncommited" through either TransactionScope or directly on the DataContext's connection.Marc Gravell : @Lucas - that isn't very granular
0 comments:
Post a Comment