All of the examples I have found on here refer to inserting a sequence of a class using the following syntax:
var people = new[]
{
new Person { Age = 1, Name = "Foo" },
new Person { Age = 2, Name = "Bar" }
};
await conn.Execute("INSERT INTO People (Age, Name) VALUES (@Age, @Name)", people);
However I need to insert a sequence of Strings e.g.
var stuff = new[] {"A", "B", ... };
await conn.Execute("INSERT INTO someTable (Entry) VALUES (@stuff)", stuff);
The above does not work, what syntax should I be using?
Since you sequence is really large, I would do everything using a bulk load technique for maximum performances. Just use SqlBulkCopy class:
https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy(v=vs.110).aspx
The others option are
1) using Table Valued Parameters, supported by Dapper natively: https://medium.com/dapper-net/sql-server-specific-features-2773d894a6ae
2) Create single JSON with all of your data (or maybe, even better, create several JSON document to mimic a batched load) and use the native JSON support of SQL Server 2016+ to do the job.
just keep in mind that if you just want really good peformances the only way is the SqlBulkCopy option