最近需要将一些业务数据同步到另一个库中,于是想到了dapper的扩展,用到了它的批量插入,特地记录一下基础用法。
1、添加Dapper和Dapper.Contrib
2、链接
var conn = new SqlConnection(ConfigurationManager.ConnectionStrings[“DbConn”].ConnectionString);
3、查询
string query = "SELECT * FROM User WHERE name = @name";
var userList = conn.Query<User>(query, new {name = "zhangsan"}