Dapper Contrib - Easy CRUD Method

So far, we have looked at CRUD operations by implementing the operations ourselves using SQL.

Dapper Contrib takes it up one step further and provides us with a neat methods to do the CRUD tasks for us.

For example - notice the difference between GetAll() and UpdateAll()

UserRepository.cs

Dapper.Contrib has the following Generic Members available to us:

T Get<T>(id);
IEnumerable<T> GetAll<T>();
int Insert<T>(T obj);
int Insert<T>(Enumerable<T> list);
bool Update<T>(T obj);
bool Update<T>(Enumerable<T> list);
bool Delete<T>(T obj);
bool Delete<T>(Enumerable<T> list);
bool DeleteAll<T>();
Dapper.Contrib Generic Members

For a more detailed breakdown of what the code does, you can refer to the Dapper repository on Github, its open source which is fantastic!

StackExchange/Dapper
Dapper - a simple object mapper for .Net. Contribute to StackExchange/Dapper development by creating an account on GitHub.

More on this -

Performing Inserts and Updates with Dapper
I am interested in using Dapper - but from what I can tell it only supports Query and Execute. I do not see that Dapper includes a way of Inserting and Updating objects. Given that our project (m...

Hope this helps.

Post Picture: Overlooking From A Plane , Fiji Islands. Shot by: VijeshDattPhotography.

During the current Global Pandemic, International Travel is restricted and we cannot welcome tourists at the moment. In the meantime, I hope that I can share with you the beauty of Fiji through my blog.

Here is an excellent message from Fiji Airways.

When the time is right we will be here to welcome you back to our home. From our Fijian family to yours…Sota Tale. It’s not goodbye, just see you later.