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 int OrderDetailID { get; set; }
public int OrderID { get; set; }
public int ProductID { get; set; }
public int Quantity { get; set; }
public static void Main()
string sqlOrderDetails = "SELECT TOP 5 * FROM OrderDetails;";
string sqlOrderDetail = "SELECT * FROM OrderDetails WHERE OrderDetailID = @OrderDetailID;";
string sqlCustomerInsert = "INSERT INTO Customers (CustomerName) Values (@CustomerName);";
using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
var orderDetails = connection.Query<OrderDetail>(sqlOrderDetails).ToList();
var orderDetail = connection.QueryFirstOrDefault<OrderDetail>(sqlOrderDetail, new {OrderDetailID = 1});
var affectedRows = connection.Execute(sqlCustomerInsert, new {CustomerName = "Mark"});
Console.WriteLine(orderDetails.Count);
Console.WriteLine(affectedRows);
FiddleHelper.WriteTable(orderDetails);
FiddleHelper.WriteTable(new List<OrderDetail>() { orderDetail });