与 C# 4.0 一起使用的最佳 ORM [英] Best ORM to use with C# 4.0

查看:25
本文介绍了与 C# 4.0 一起使用的最佳 ORM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最好的方法是使用像 Nhiberate 或实体框架这样的 ORM 或做一个客户 ORM.我将在 C# 4.0 项目中使用这个 ORM

what is the best way is to use a ORM like Nhibertate or Entity Framework or to do a customer ORM . I will use this ORM for a C# 4.0 project

推荐答案

UPDATE 2016

六年后,情况大不相同.NHibernate 几乎被放弃了,其他替代品也被放弃了(例如 Subsonic),实体框架可能是最常见的全功能 ORM,人们已经转向像 Dapper 多年来,以最小的开销从查询映射到对象.

Six years later things are VERY different. NHibernate is all but abandoned, other alternatives were abandoned (eg Subsonic), Entity Framework is perhaps the most common full-featured ORM, and people have been moving to micro ORMs like Dapper for years, to map from queries to objects with a minimum of overhead.

应用场景也发生了变化.Web 服务和 REST API 需要为大量较小的请求提供服务,而不是以内存和性能为代价加载和缓存一个大对象图.这意味着不再可以接受完整的 ORM 开销.

The application scenarios have also changed. Instead of loading and caching one big object graph at the expense of memory and performance, Web Services and REST APIs need to service a high number of smaller requests. This means that a full ORM's overhead is no longer acceptable.

这意味着 Active Record、每个请求的事务等模式和技术已经成为扼杀反模式的吞吐量和可扩展性

This means that patterns and techniques like Active Record, transaction per request etc have become throughput and scalability killing anti-patterns

当今最重要的功能之一是异步执行,以减少由于等待而造成的线程和 CPU 浪费.NHibernate 从未进行过这种转变.

One of the most important features nowadays is asynchronous execution , to reduce thread and CPU waste due to waits. NHibernate never made this transition.

原答案

定义最佳":它是最成熟的、拥有更多文档、更大社区、更主流的那个吗?

Define "best": Is it the most mature, the one with more documentation, bigger community, more mainstream?

NHibernate 更成熟、功能更丰富、社区更先进,并且不太可能在 MS 决定停止使用时停产再次破坏兼容性.Entity Framework 更主流,支持开箱即用.你会发现更多的 EF 初学者书籍,更多 NH 的高级书籍.

NHibernate is more mature, feature rich, with a more advanced community and not likely to be discontinued when MS decides to break compatibility again. Entity Framework is more mainstream and is supported out-of-the-box. You will find more beginner books for EF, more advanced books for NH.

一个不错的选择是尝试一种更简单的 ORM,比如 Subsonic,一旦你了解了 ORM 的工作原理、各种陷阱是什么、什么是 SELECT N+,就转向更高级的 ORM1 表示 [:P]

A good option would be to try one of the simpler ORMs like Subsonic and move to more advanced ORMs once you understand how ORMs work, what are the various pitfalls, what SELECT N+1 means [:P]

不要尝试创建自己的 ORM,已经有几十个了!Subsonic、Castle ActiveRecord、NH、EF(当然)、LLBLGenPro...

Just don't try to create your own ORM, there are several dozens out there already! Subsonic, Castle ActiveRecord, NH, EF (of course), LLBLGenPro...

这篇关于与 C# 4.0 一起使用的最佳 ORM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆