Dapper.NET 在C#中使用Dapper
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);
}
}
}将连接包装在一个Using块中将关闭连接