1

I am using Dapper.NET for my database connections.

So far, I have resorted to hand writing all the SQL I need for Inserts and Updates, I've found this old post from Sam Saffron
Performing Inserts and Updates with Dapper

However, it doesn't lead to anything conclusive with regards to how to do inserts and updates from POCO objects, other than a few links to code that are several years old by now.

Since then, has a new small helper library to autogenerate what is needed popped up?

Community
  • 1
  • 1
Jesper Bangsholt
  • 544
  • 4
  • 11

1 Answers1

0

You can use Dapper.Contrib

//Insert one entity
connection.Insert(new Car { Name = "Volvo" });

//Insert a list of entities
connection.Insert(cars);

//Update one entity
connection.Update(new Car() { Id = 1, Name = "Saab" });

//Update a list of entities
connection.Update(cars);

See more examples here.

Alex Erygin
  • 3,161
  • 1
  • 22
  • 22