SQL Server NOLOCK

43 views
Skip to first unread message

Thiago Conti

unread,
Jan 15, 2015, 6:55:22 AM1/15/15
to simpl...@googlegroups.com
Hello all,

I've just started using Simple.Data with SQL Server.

Could you help me with a simple question?
Is there a way to use something similar to NOLOCK (READ UNCOMMITED) when retrieving data?

Thanks in advance.

Mike Woods

unread,
Jan 28, 2015, 1:10:02 PM1/28/15
to simpl...@googlegroups.com
I've spent all day looking into this as well.  From what I can tell, you can wrap a statement in a using a transaction.  

using (var transaction = database.BeginTransaction())
{
   transaction.Users.Insert(Name: "Steve", Age: 50);
   transaction.Commit();
}

What they don't tell you here is that you can pass an IsolationLevel enum value into BeginTransaction so that it looks like this:
using (var transaction = database.BeginTransaction(IsolationLevel.ReadUncommitted))
{
   transaction.Users.Insert(Name: "Steve", Age: 50);
   transaction.Commit();
}

Thiago Conti

unread,
Feb 3, 2015, 6:02:21 AM2/3/15
to simpl...@googlegroups.com
Thanks for your help!!!

--
You received this message because you are subscribed to the Google Groups "Simple.Data" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simpledata+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages