using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.Data.SqlClient;
public static void Main()
DapperPlusManager.Entity<Product>("InsertName_WithMap")
.Identity(x => x.ProductID)
.Map(x => new { x.Name });
DapperPlusManager.Entity<Product>("InsertName_With_ColumnPrimaryKeyExpression")
.UseBulkOptions(options => {
options.ColumnPrimaryKeyExpression = x => new { x.ProductID };
options.ColumnInputExpression = x => new { x.Name };
DapperPlusManager.Entity<Product>("InsertName_With_ColumnInputNames")
.UseBulkOptions(options => {
options.ColumnPrimaryKeyExpression = x => new { x.ProductID };
options.ColumnInputNames = new List<string>() { nameof(Product.Name) };
var products = new List<Product>();
products.Add(new Product() { Name = "Dapper Plus", Description = @"Use <a href=""https://dapper-plus.net/"" target=""_blank"">Dapper Plus</a> to extend your IDbConnection with high-performance bulk operations." });
products.Add(new Product() { Name = "C# Eval Expression", Description = @"Use <a href=""https://eval-expression.net/"" target=""_blank"">C# Eval Expression</a> to compile and execute C# code at runtime." });
products.Add(new Product() { Name = "Entity Framework Extensions", Description = @"Use <a href=""https://entityframework-extensions.net/"" target=""_blank"">Entity Framework Extensions</a> to extend your DbContext with high-performance bulk operations." });
var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServer());
connection.CreateTable<Product>();
connection.BulkInsert("InsertName_WithMap", products);
connection.BulkInsert("InsertName_With_ColumnPrimaryKeyExpression", products);
connection.BulkInsert("InsertName_With_ColumnInputNames", products);
FiddleHelper.WriteTable(connection.Query<Product>("SELECT * FROM Product"));
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ProductID { get; set; }
public string Name { get; set; }
public string Description { get; set; }