using System.Data.SqlClient;
using System.Collections.Generic;
public static void Main()
Guid guid = Guid.NewGuid();
var customer = new Customer()
using (var conn = new SqlConnection(FiddleHelper.GetConnectionStringSqlServer()))
conn.ExecuteNonQuery(@"CREATE TABLE Customers(
Name VARCHAR (20) NOT NULL,
var dt = new DataTable();
using (var copy = new SqlBulkCopy(conn))
foreach (PropertyInfo property in customer.GetType().GetProperties())
dt.Columns.Add(property.Name, property.PropertyType);
copy.ColumnMappings.Add(property.Name, property.Name);
DataRow dr = dt.NewRow();
foreach (PropertyInfo property in customer.GetType().GetProperties())
object value = property.GetValue(customer, null);
dr[property.Name] = value == null ? DBNull.Value : value;
copy.DestinationTableName = "Customers";
var result = conn.ExecuteEntity<Customer>("SELECT TOP 1 * FROM CUSTOMERS");
var list = new List<Customer>() {result};
FiddleHelper.WriteTable(list);
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }