CruDapper – Dapper extension with CRUD functionality (and some more)

I have posted this before, but it's coming along nicely, with some more features.

In short, I found other CRUD libraries to Dapper to be lacking in basic features. I found myself writing the same boilerplate everytime, such as transactionscopes, I was limited by having Int as my primary key, I could not exclude columns from inserts. Something the current CRUD libs to Dapper lacks is working with multiple objects at the same time. Insert 10 rows = call Insert 10 times and make 10 round-trips to the database. Otherwise you just have to write manual SQL for every table you want to do multiple inserts for. Seriously ?_?

I'm also quite heavily opinionated in how I want to use my database. I'm generally against deleting rows, due to it being valuable to check historic data occasionally. This is a core function in CruDapper, and it exposes interfaces such as the following:

IEnumerable<T> GetAll<T>(bool getDeleted = false); void DeleteAll<T>(bool permanently = true); 

Thus, setting getDeleted to true will include deleted rows in your query (a bit flag in the database). setting permanently to false will not delete your rows, but rather set the same bit to true.

There's also some interesting stuff like PutIdentifiable and Merge, and a lot of reduction in boilerplate by automatically enlisting transactionscopes on all Dapper standard queries if you so wish.

The Postgres integration isn't finished done, but the MsSQL one is fully integrated so far.

Well, it's a work in progress. Check it out if you're interested.

by BlackOdder via /r/csharp

Leave a Reply