Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using System;
using System.Data.SqlClient;
using System.Linq;
using Dapper;
namespace DapperSample.SQLServer
class Program
static void Main(string[] args)
Console.WriteLine("Hello World!");
string sqlProduct = "SELECT TOP 5 * FROM [Production].[Product];";
using (var connection = new SqlConnection("Data Source=localhost;Initial Catalog=AdventureWorks2014;Integrated Security=True"))
var products = connection.Query<Product>(sqlProduct).ToList();
foreach (var item in products)
Console.WriteLine($"ProductID: {item.ProductID}; Name: {item.Name}; ProductNumber: {item.ProductNumber} ");
public class Product
public string ProductID { get; set; }
public string Name { get; set; }
public string ProductNumber { get; set; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.