using System.Collections.Generic;
using System.Data.SqlClient;
public int CustomerID {get;set;}
public string CustomerName {get;set;}
public string ContactName {get;set;}
public string Address {get;set;}
public string City {get;set;}
public string PostalCode {get;set;}
public string Country {get;set;}
public static void Main()
DapperPlusManager.Entity<Customer>().Table("Customers")
.Identity(x => x.CustomerID);
DapperPlusManager.Entity<Customer>("TheMappingKey").Table("Customers")
.Identity(x => x.CustomerID)
.Map(x => new { x.CustomerName, x.ContactName })
var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServer());
var listA = GenerateCustomers("CustomerName_A", 5);
var listB = GenerateCustomers("CustomerName_B", 5);
connection.BulkInsert(listA);
connection.BulkInsert("TheMappingKey", listB);
FiddleHelper.WriteTable("Customers:", connection.Query<Customer>("SELECT * FROM Customers WHERE CustomerName LIKE 'CustomerName_%'"));
public static List<Customer> GenerateCustomers(string prefix, int count)
var customers = new List<Customer>();
for(int i = 0; i < count; i++)
customers.Add(new Customer() { CustomerName = prefix + "_" + i, ContactName = "ContactName_" + i, Address = "Address_" + i, City = "City_" + i, PostalCode = "PostalCode_" + i, Country = "Country_" + i });
public static void GenerateDatabase()
using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServer()))
using (var command = connection.CreateCommand())
[CustomerID] [INT] IDENTITY(1,1) NOT NULL,
[CustomerName] [NVARCHAR](255) NULL,
[ContactName] [NVARCHAR](255) NULL,
[Address] [NVARCHAR](255) NULL,
[City] [NVARCHAR](255) NULL,
[PostalCode] [NVARCHAR](255) NULL,
[Country] [NVARCHAR](255) NULL,
CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED
command.ExecuteNonQuery();