1.表结构
2、程序对应的实体类
3、基本操作
-
3.1 插入
1 2 3 4 5 6 7 8 9
public int Insert(Person person, string _ConnString) { using (IDbConnection connection = new SqlConnection(_ConnString)) { return connection.Execute("insert into Person(Name,Remark) values(@Name,@Remark)", person); } }
-
3.2 删除
1 2 3 4 5 6 7
public int Delete(Person person, string connectionString) { using (IDbConnection connection = new SqlConnection(connectionString)) { return connection.Execute("delete from Person where id=@ID", person); } }
-
3.3 修改
1 2 3 4 5 6 7
public int Update(Person person, string connectionString) { using (IDbConnection connection = new SqlConnection(connectionString)) { return connection.Execute("update Person set name=@Name where id=@ID", person); } }
-
3.4 查询
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
///
/// 批量修改 /// /// /// ///public int Update(List persons, string connectionString) { using (IDbConnection connection = new SqlConnection(connectionString)) { return connection.Execute("update Person set name=@name where id=@ID", persons); } } /// /// 无参查询所有数据 /// ///public List Query(string connectionString) { using (IDbConnection connection = new SqlConnection(connectionString)) { return connection.Query ("select * from Person").ToList(); } } - 其余内容: