toptensoftware/PetaPoco — pull request #172 by alexdancho (2013-11-09 21:47:58+00:00)
Title: Adds support for specifying isolation level both globally at at the transaction level.

So in [this StackOverflow question](http://stackoverflow.com/questions/19862748/petapoco-setting-transaction-isolation-level), I asked about the possibility of specifying an isolation level for transactions while using PetaPoco. Since it looked like - at least on initial glance - there wasn't any way to do this without actually prepending `"SET TRANSACTION LEVEL [LEVEL]"` before each query, I added in a way to specify isolation level.

At the transaction level:

```csharp
var newObject = new NewObject();
var newObjectId = 1;
using (var scope = db.GetTransaction(IsolationLevel.ReadUncommitted))
{
newObject = db.SingleOrDefault("SELECT * FROM tblNewObject WHERE Id = @0", newObjectId);
scope.Complete();
}
```

...and at the database level (specifically, in this case, using Autofac as the IoC):

```csharp
builder.Register(a => new PetaPoco.Database("connectionStringName") { DefaultIsolationLevel = IsolationLevel.ReadUncommitted }).As().InstancePerLifetimeScope();
```

I would like to expand out to being able to provide an isolation for the LINQ-esque methods without having to explicitly manage transactions, but without further examination of the source, I can't determine whether or not that would have adverse effects. For now, I think this is a good way to be able to provide some level of transaction isolation control.