在 ASP.NET 中使用存储过程的更好方法?

发布于 2024-10-13 02:36:37 字数 812 浏览 1 评论 0原文

我目前在一家小型 ASP.NET/MS-SQL 商店工作。我的团队注意到我们的大量开发(和错误修复)时间都花在了 ADO.NET 数据库访问代码上。我们正在寻找一种软件解决方案,以简化将 DataTable/SQLDataReader 结果映射到正确业务对象的过程。手动指定列名并转换结果正在成为一场噩梦(特别是当涉及架构更改时)。

到目前为止,Entity Framework(以及较小程度上的 LINQ-to-SQL)是我们发现的唯一可以很好地自动化此过程的软件。我们只需将存储过程添加到模型中,并让它们返回自动生成的复杂类型。从数据库更新模型的能力也是一大优势。

在我们开始将许多项目迁移到实体框架之前,我想知道是否还有其他我们应该考虑的选项。我的团队对 ORM 库或代码生成器没有强烈的偏好。

一些可能有帮助的标准:

  1. 所有数据访问(包括 CRUD)都是通过 SQL Server 2008R2 上的存储过程执行的。 请不要回答“停止使用存储过程”。 ORM 在我们的情况下会产生难以置信的意义,但我们的 DBA 的决定胜过编程团队的决定。
  2. 软件应该帮助解析 SPROC 参数名称并将结果转换为我们可以使用的某种强类型对象。
  3. 我们是一个预算非常少的学术机构。今年我们几乎用完了预算(我们获得了 Resharper 许可证 - 值得庆幸的是价格降低了),因此价格昂贵的商业解决方案已经退出。
  4. 我们无法使用 GPL 库。 LGPL/BSD 或任何类似的都可以
  5. 我们希望让开发人员的事情变得更容易。将列/类型信息从 C# 转移到手动编写的 XML 并没有真正使他们的工作变得更容易。我们正在寻找尽可能自动化的东西。

I'm currently employed at a small ASP.NET/MS-SQL shop. My team has noticed that a very large amount of our development (and bugfixing) time is spent on our ADO.NET Database Access code. We're looking for a software solution that eases the process of mapping the DataTable/SQLDataReader results to proper business objects. Manually specifying column names and casting the results is becoming a nightmare (especially when schema changes are involved).

So far, Entity Framework (and to a lesser extent, LINQ-to-SQL) has been the only piece of software we've found that automates this process fairly well. We simply add our stored procedures to the model and let them return auto-generated Complex Types. The ability to update the model from the database is also a big plus.

Before we start migrating any of our many projects to Entity Framework, I was wondering if there are any other options that we should look at. My team has no strong preference between ORM libraries or Code Generators.

Some of the criteria that might help:

  1. All data access (including CRUD) is performed through Stored Procedures on SQL Server 2008R2. Please don't answer "stop using stored procedures". An ORM would make an incredible amount of sense in our situation, but our DBA's decision trumps the programming team's.
  2. Software should help with resolving SPROC parameter names and with converting the result into some strongly typed object we can work with.
  3. We're an academic institution with a very small budget. We've pretty much expended our budget this year (we got Resharper licenses - thankfully at a reduced price), so commercial solutions with a hefty price tag are out.
  4. We are not able to use GPL libraries. LGPL/BSD or anything similar are fine
  5. We're looking to make things easier for our developers. Moving the column/type information from C# to manually-written XML doesn't really make their jobs any easier. We're looking for something as automated as possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

海之角 2024-10-20 02:36:37

您应该认真看一下类型映射 OR/M & Software is Hardwork Library 的生成器位于:

http://code.google.com/p/softwareihardwork/

You should seriously take a look at the Type Map OR/M & generator from Software is Hardwork Library at:

http://code.google.com/p/softwareishardwork/

她如夕阳 2024-10-20 02:36:37

就我个人而言,当我遇到这种情况时,我是 iBatis.NET 的粉丝。据我所知,它已不再开发,但它的后继者 MyBatis 可能也是一个不错的选择。

Personally, I'm a fan of iBatis.NET when stuck in this situation. As far as I know, it's no longer in development, but its successor MyBatis may be a good option as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文