I am using C# Dapper with MYSQL.
I have a list of classes that i want to insert into MySQL table.
I used to do it using TVP in MS SQL, how do we do it in MySQL.
解决方案
Disclaimer: I'm the owner of Dapper Plus
This project is not free but supports MySQL and offers all bulk operations:
BulkInsert
BulkUpdate
BulkDelete
BulkMerge
And some more options such as outputting identity values:
// CONFIGURE & MAP entity
DapperPlusManager.Entity()
.Table("Orders")
.Identity(x => x.ID);
// CHAIN & SAVE entity
connection.BulkInsert(orders)
.AlsoInsert(order => order.Items);
.Include(x => x.ThenMerge(order => order.Invoice)
.AlsoMerge(invoice => invoice.Items))
.AlsoMerge(x => x.ShippingAddress);