建议 .NET 上的简单 ORM - 设计用于维护遗留应用程序
我被指派维护一堆遗留应用程序,这些应用程序大量使用存储过程,这些应用程序是在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
看看 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.
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.
我建议你使用 PetaPoco,这是一个相当新鲜的 ORM,易于学习。
来自作者网站:
I suggest you to use PetaPoco, the quite fresh ORM with easy to learn line.
From authors site:
我在 .NET 2.0 项目中使用了 Subsonic,效果很好。不幸的是,它似乎不再被开发了。
I used Subsonic in .NET 2.0 projects and it was nice. Unfortunately, it seems, it is not developed anymore.
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.