using System.Collections.Generic;
using System.Data.SqlClient;
public int SupplierID {get;set;}
public string SupplierName {get;set;}
public Product Product {get;set;}
public int ProductID {get;set;}
public string ProductName {get;set;}
public static void Main()
List<Supplier> suppliers = new List<Supplier>();
using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
connection.Query("Update OrderDetails set ProductID = 11");
suppliers = connection.Query<Supplier, Product, Supplier>("Select TOP 1 A.SupplierID, A.SupplierName, B.ProductID, B.ProductName FROM Suppliers as A inner join Products as B on B.SupplierID =A.SupplierID where productID = 24",(supplier, product) => { supplier.Product = product; return supplier; },splitOn: "ProductID").ToList();
FiddleHelper.WriteTable(suppliers);
DapperPlusManager.Entity<Supplier>().Table("Suppliers").Identity(x => x.SupplierID);
DapperPlusManager.Entity<Product>().Table("Products").Identity(x => x.ProductID);
using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
connection.BulkDelete(suppliers.Select(x => x.Product)).BulkDelete(suppliers);
using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
suppliers = connection.Query<Supplier, Product, Supplier>("Select TOP 1 A.SupplierID, A.SupplierName, B.ProductID, B.ProductName FROM Suppliers as A inner join Products as B on B.SupplierID =A.SupplierID where productID = 24",(supplier, product) => { supplier.Product = product; return supplier; },splitOn: "ProductID").ToList();
Console.WriteLine("Row count after delete: " + suppliers.Count());