我需要为N层应用程序仔细选择.NET ORM .这意味着I将拥有服务器(WCF服务),它公开数据,客户机将显示数据。ORM应该平稳地支持所有相关的序列化问题--对象或对象集合,或者任何必须跨越进程边界的东西。理想情况下,多进程环境中的使用应该与在单个进程中相同。
标准是:
发布于 2010-07-15 01:41:47
我推荐实体框架v4。自v1以来,它已经大大改进了,并且支持您所需的一切,除了开源之外:
发布于 2010-07-15 03:44:05
与以下方面合作:
我可以肯定地说,DataTables只是在开玩笑。他们都有自己的长处和弱点。
主要是,我发现这些优点与ORM的一般类型有关,ORM可分为以下两类。
- LLBLGen, OpenAccess, Entity Framework (pre 4.0), DataObjects all fall into this category. Heavy weight ORMs typically have entities and collections that inherit from a base class specific to the ORM (ie. EntityBase). These ORMs often offer rich design time support, code generation and in depth runtime features (such as state tracking, transaction tracking, association maintanance, etc.).
- The Pro: Easier, faster development upfront leveraging the built in API for interacting with entities themselves at runtime (ie. from LLBLGen entity.Fields["MyField"].IsChanged or entity.IsNew or entity.Fields["MyField"].DbValue
- The Con: Heaviness and dependencies. With these ORMs, your business objects are now tied directly into the ORM API. What if you want to change to another ORM? And what's to prevent junior developers from abusing advanced features of the ORM API to fix a simple problem with a complex solution (I've seen this a ton)? Memory usage is also a big problem with these ORMs. A collection of 5,000+ entities can easily take up 100MB of RAM with some of the above ORMs. Serialization is another problem. With the heaviness of the objects, serialization can be very slow...and it probably won't work correctly deserializing on the other side of the wire (WCF or .NET remoting, etc.). Associations may end up not re-associated correctly or certain fields may not be preserved. Several of the ORMs above have built in serialization mechanisms to improve support and speed...but none that I've seen offer full support for different formats (ie. you get binary, but not json or xml serialization support).
- LINQ to SQL, Entity Framework POCO, NHibernate (sort of) fall into this cateogry. Light-weight ORMs typically use POCOs that you can design yourself in a file in VS (of course you can use a T4 template or a code generator too).
- The Pro: Lightweight. Keeps it simple. ORM agnostic business objects.
- The Con: Less features, such as entity graph maintance, state tracking, etc.
不管您选择什么ORM,我个人的偏好是坚持LINQ和ORM独立的检索语法(如果ORM有自己的抓取API,则不是ORM自己的获取API)。
关于提到的具体问题,以下是我的简短想法:- NHibernate:落后于时代的科技智慧。xml映射文件的许多维护性(尽管Fluent NHibernate确实减轻了这一点)。
发布于 2010-07-15 01:31:03
为什么不试试NHibernate呢?
https://stackoverflow.com/questions/3251849
复制相似问题