1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
/// <summary> /// 批量修改 /// </summary> /// <param name="persons"></param> /// <param name="connectionString"></param> /// <returns></returns> public int Update(List<Person> persons, string connectionString) { using (IDbConnection connection = new SqlConnection(connectionString)) { return connection.Execute("update Person set name=@name where id=@ID", persons); } }
/// <summary> /// 無參查詢全部數據 /// </summary> /// <returns></returns> public List<Person> Query(string connectionString) { using (IDbConnection connection = new SqlConnection(connectionString)) { return connection.Query<Person>("select * from Person").ToList(); } } |