using System.Data.SqlClient;
public int CustomerID { get; set; }
public string Code { get; set; }
public string Name { get; set; }
public static void Main()
var dt = new DataTable();
for(int i = 0; i < 5; i++) {
dt.Rows.Add("Code_" + i, "Name_" + i);
var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServer());
connection.Execute("Customer_Seed", new { Customers = dt.AsTableValuedParameter("TVP_Customer") }, commandType: CommandType.StoredProcedure);
FiddleHelper.WriteTable("1 - Customers", connection.Query<Customer>("SELECT * FROM Customer"));
public static void CreateDatabase()
var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServer());
[CustomerID] [INT] IDENTITY(1,1) NOT NULL,
[Code] [VARCHAR](20) NULL,
[Name] [VARCHAR](20) NULL,
CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED
CREATE TYPE TVP_Customer AS TABLE
[Code] [VARCHAR](20) NULL,
[Name] [VARCHAR](20) NULL
CREATE PROCEDURE Customer_Seed
@Customers TVP_Customer READONLY
INSERT INTO Customer (Code, Name)