Dapper ORM (2) - 使用存储过程

Dapper 作为一款轻量级的 ORM 包,需要开发者来编写 SQL 语句。如果将 SQL 语句放在存储过程中,则 C# 中的代码非常少。本篇接着上一篇 Dapper 文章,讲解 Dapper 使用存储过程的方法。

示例数据库使用 Sql Server Express,通过 SSMS 创建 5 个存储过程:

  • 创建 employee:

  • 修改 employee

  • 删除 employee
  • SELECT 语句,提供三种查看方法:

在 DapperHelper 中,增加 3 个方法:

EmployeeService 类中 CRUD 的代码大大简化:


源码:

github : DapperDemo - Stored Procedure

猜你喜欢

转载自blog.csdn.net/stone0823/article/details/108160562
今日推荐