I'm implementing Repository Pattern using ServiceStack.ORMLite like this:
public class MyRepository : IMyRepository
{
private IDbConnectionFactory DbConnectionFactory = null;
public MyRepository(IDbConnectionFactory dbConnectionFactory)
{
DbConnectionFactory = dbConnectionFactory;
}
public void MyMethod()
{
using (var connection = DbConnectionFactory.OpenDbConnection())
using (var cmd = connection.CreateCommand())
{
//Do something here
}
}
}
But I don't know how to handle DbTransaction when I need to warp some DB operation in a DbTransaction.It looks like TransactionScope
is a solution but I don't know whether is way too heavy for this.