建议 .NET 上的简单 ORM - 设计用于维护遗留应用程序

发布于 2024-11-08 21:29:17 字数 475 浏览 7 评论 0原文

我被指派维护一堆遗留应用程序,这些应用程序大量使用存储过程,这些应用程序是在 05 年之前构建的,当时还没有 ORM。与我一起工作的开发人员不了解实体框架,也不了解 LINQ,也不愿意学习。

.NET 上是否有任何 ORM 可以为现有数据库表和存储过程提供简单的对象接口?

如果它使我能够编写几行代码来为每个表获取一个类,并且它具有与每列中的数据相对应的属性以及一些用于解决外键关系/多对多关系 - 转发的方法或属性,我会非常高兴并反转。

例如,

Employee e = new Employee("John", null);
Department d = new Department("QA");
d.save();
e.department = d;
e.save();

无需编写 INSERT SQL 语句即可保存一条员工和部门记录。

编辑: 我正在使用 MS SQL Server 2008

I am assigned to maintain a bunch of legacy apps with heavy stored procedure usage built before '05 when there was no ORM. The developers who work with me don't know Entity Framework nor LINQ and are not eager to learn.

Is there any ORM on .NET that provides a simple object interface to existing database tables and perhaps stored procedures?

I am quite happy if it enables me to code a few lines to get a class to each table, and it has properties corresponding to data in each column and some methods or properties to resolve foreign key relationship / many-to-many relationship - forward and reverse.

For example, saving one employee and department record

Employee e = new Employee("John", null);
Department d = new Department("QA");
d.save();
e.department = d;
e.save();

without writing INSERT SQL statements.

EDIT:
I am using MS SQL Server 2008

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

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

发布评论

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

评论(5

陌生 2024-11-15 21:29:17

看看 Rob Conery 的 Massive。它很简单并且看起来很容易使用。不过,看起来它需要 .NET 4。

Have a look at Rob Conery's Massive. It's simple and appears easy to use. It looks like it requires .NET 4, though.

七禾 2024-11-15 21:29:17

SubSonic 相当容易使用。 LINQ to SQL 也是一个不错的选择。另外,请查看 http://www.codeproject.com/KB/database/LightORMLibrary .aspx

SubSonic is fairly easy to use. LINQ to SQL is a good choice too. Also, take a look at http://www.codeproject.com/KB/database/LightORMLibrary.aspx.

白衬杉格子梦 2024-11-15 21:29:17

我建议你使用 PetaPoco,这是一个相当新鲜的 ORM,易于学习。

来自作者网站:

PetaPoco 最初的灵感来自 Rob Conery 的 Massive 项目,但适用于非动态 POCO 对象。它的出现是因为我发现我的许多使用 SubSonic/Linq 的项目都很慢或者变成了 Linq 和 CodingHorror 的混合体。

我需要一个小型、快速、易于使用并且可以在 .NET 3.5 和/或 Mono 2.6 上运行的数据访问层(即:不支持动态扩展)。 Rob 声称 Massive 只有 400 行代码引起了我的兴趣,我想知道是否可以在没有动态的情况下完成类似的事情。

I suggest you to use PetaPoco, the quite fresh ORM with easy to learn line.

From authors site:

PetaPoco was original inspired by Rob Conery's Massive project but for use with non-dynamic POCO objects. It came about because I was finding many of my projects that used SubSonic/Linq were slow or becoming mixed bags of Linq and CodingHorror.

I needed a data acess layer that was tiny, fast, easy to use and could run on .NET 3.5 and/or Mono 2.6 (ie: no support for dynamic expandos). Rob's claim of Massive being only 400 lines of code intruiged me and I wondered if something similar could be done without dynamics.

以可爱出名 2024-11-15 21:29:17

我在 .NET 2.0 项目中使用了 Subsonic,效果很好。不幸的是,它似乎不再被开发了。

I used Subsonic in .NET 2.0 projects and it was nice. Unfortunately, it seems, it is not developed anymore.

春庭雪 2024-11-15 21:29:17

NHibernate 也可能是值得研究的东西,虽然我个人不太喜欢最初的 Java Hibernate,但那是好几年了前。我还定期使用 SubSonic。最新的 SubSonic 更面向 Linq,但请特别关注其“ActiveRecord”功能。我认为它涵盖了您正在尝试做的基于对象的事情。除了偶尔修复错误之外,SubSonic 的开发已经不再发生,但它是开源的,并且有一个 Google 小组来解答支持问题。它还支持大量数据库,因为您没有提到您正在使用什么数据库。

NHibernate may be something to look into also, though personally I didn't like the original Java Hibernate very much, but that was years ago. I also use SubSonic on a regular basis. The latest SubSonic is more Linq oriented, but look specifically at its "ActiveRecord" capability. I think it covers the object-based stuff that you are trying to do. Development on SubSonic doesn't happen much any more, other than occasional bug fixes, but it is open source, and there is a Google group for support questions. It also supports a good number of databases, since you didn't mention what DB you are using.

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