ServiceStack OrmLite transaction support

I am a big fan of the ServiceStack OrmLite framework.

To quote from them directly :

OrmLite’s goal is to provide a convenient, DRY, config-free, RDBMS-agnostic typed wrapper that retains a high affinity with SQL, exposing intuitive APIs that generate predictable SQL and maps cleanly to (DTO-friendly) disconnected POCO’s.

This approach makes easier to reason about your data access making it obvious what SQL is getting executed at what time, whilst mitigating unexpected behaviour, implicit N+1 queries and leaky data access prevalent in Heavy ORMs.

I have been working on a fairly big project and have abstracted the data access away into a separate class library and wanted to have a Commit() method that allowed multiple repositories’s to do their thing and to save across tables in a transactional way.

So here is an example of how I have done that:

The ServiceStack OrmLite API is very nice and maps to the IDbConnection interface nicely. Do check it out.

alt text