38
1
// @nuget: Dapper -Version 1.60.6
2
using Dapper;
3
using System;
4
using System.Collections.Generic;
5
using System.Data.SqlClient;
6
using System.Linq;
7
8
public class Program
9
{
10
public class Customer
11
{
12
public int CustomerID {get;set;}
13
public string CustomerName {get;set;}
14
public string ContactName {get;set;}
15
public string Address {get;set;}
16
public string City {get;set;}
17
public string PostalCode {get;set;}
18
public string Country {get;set;}
19
}
20
21
public static void Main()
22
{
23
using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
24
{
25
connection.Execute("INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway');");
26
}
27
28
29
using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
30
{
31
var customer = connection.Query<Customer>("Select * FROM CUSTOMERS Where CustomerName ='Cardinal'").ToList();
32
33
Console.WriteLine("Row Insert : " + customer.Count());
34
35
FiddleHelper.WriteTable(connection.Query<Customer>("Select TOP 10 * FROM CUSTOMERS Where CustomerName like 'C%'").ToList());
36
}
37
}
38
}
Cached Result
10