Skip to content
Advertisement

Insert a list using dapper.NET C#

I’d like to insert a list of objects in an SQL table.

I know this question here but I don’t understand.

Here is my class :

I’d like to know how could I insert my list using Dapper, I don’t want to iterate on the list and save them one by one, I would like to insert all of them in one request.

Advertisement

Answer

You can insert these just as you would INSERT a single line:

Dapper will look for class members named after your SQL parameters (@Id, @ObjectType, @Content, @PreviewContent) and bind them accordingly.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement