using System.Data;
using System.Linq;
using Dapper;
class Program
{
static void Main()
{
using (IDbConnection db = new SqlConnection("Server=myServer;Trusted_Connection=true"))
{
db.Open();
var result = db.Query<string>("SELECT 'Hello World'").Single();
Console.WriteLine(result);
}
}
}
Wrapping the connection in a Using
block will close the connection