none
Optimisation hints RRS feed

  • Question

  • I have a SQL Server database table that I know will never be written to (apart from nightly updates).

    When I queried this table using SQL, I found that there was a performance gain to be had if I told SQL Server that I didn't want to place any locks or to take any notice of any locks, so something like:

    select * from Products (no lock) where Products.Code = @code

    Is there a way to introduce similar hints when using LINQ?

    Thanks

    Griff
    Tuesday, November 11, 2008 12:17 PM

Answers

  • Use a transaction scope with isolation set to readuncommitted...

     

    Code Snippet

    using (TransactionScope ts = new TransactionScope(

        TransactionScopeOption.Required,
        new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted }))
    {
        using (SomeDataContext dc = new SomeDataContext())
        {
            ...
        }
    }

     

     

    Tuesday, November 11, 2008 3:17 PM
    Answerer