using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.Data.SqlClient;
public static void Main()
DapperPlusManager.Entity<Product>()
.Identity(x => x.ProductID)
x.DeleteMatchedAndConditionExpression = y => new { y.Version };
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.", Version = "2" });
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.", Version = "2" });
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.", Version = "2" });
var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServer());
connection.CreateTable<Product>();
connection.BulkInsert(products);
FiddleHelper.WriteTable("1 - Product (Before)", connection.Query<Product>("SELECT * FROM Product"));
products.Last().Version = "3";
connection.BulkDelete(products);
FiddleHelper.WriteTable("3 - Product (After)", connection.Query<Product>("SELECT * FROM Product"));
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ProductID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Version { get; set; }