简体   繁体   English

NHibernate,Castle,Linq之间的差异 - 他们的目标是谁?

[英]Differences between NHibernate, Castle, Linq - Who are they aimed at?

This answer says that Linq is targeted at a slightly different group of developers than NHibernate, Castle, etc. 这个答案说 Linq针对的是一组与NHibernate,Castle等略有不同的开发人员。

Being rather new to C#, nevermind all the DB stuff surrounding it: 作为C#的新手,永远不要涉及它周围的所有数据库内容:

  • Are there other major, for lack of a better term, SQL wrappers than NHibernate, Castle, Linq? 还有其他专业,因为缺乏更好的术语,SQL包装器比NHibernate,Castle,Linq?
  • What are the differences between them? 它们之间有什么区别?
  • What kind of developers or development are they aimed at? 他们针对什么样的开发者或开发?

-Adam -亚当

When you say Castle I assume you mean Castle Active Record? 当你说Castle我认为你的意思是Castle Active Record?

The difference is NHibernate is an OR/M and is aimed at developers who want to focus on the domain rather than the database. 不同之处在于NHibernate是一个OR / M,面向那些想要专注于域而不是数据库的开发人员。 With linq to sql, your database is pre-existing and you're relationships and some of programming will be driven by how your database is defined. 使用linq to sql,您的数据库是预先存在的,并且您是关系,并且一些编程将由您的数据库定义方式驱动。

Now between NHibernate and Castle ActiveRecord -- they are similar in that you're driving your application design from the domain but with NHibernate you provide mapping xml files (or mapping classes with fluent NHibernate) where in Active Record you are using the convention over configuration (using attributes to define any columns and settings that don't fit naturally). 现在介于NHibernate和Castle ActiveRecord之间 - 它们的相似之处在于你从域中驱动你的应用程序设计,但是使用NHibernate你提供映射xml文件(或者用流畅的NHibernate映射类),在Active Record中你使用约定优于配置(使用属性定义任何不适合的列和设置)。 Castle Active record is still using NHibernate in the background. Castle Active记录仍然在后台使用NHibernate。

One OR/M is not necessarily the 'one true way' to go. 一个OR / M不一定是“一个真正的方式”。 It depends on your environment, the application your developing and your team. 这取决于您的环境,您的开发人员和您的团队的应用程序。

You may also want to check out SubSonic . 您可能还想查看SubSonic It's great for active record but it is not for project where you want to focus mainly on your Domain. 它对于活动记录非常有用,但它不适用于您希望主要关注域的项目。 Depending on the project, I usually use either NHibernate (with Castle Active Record) or Subsonic 根据项目的不同,我通常使用NHibernate(使用Castle Active Record)或Subsonic

Actually we use both Linq and NHibernate together (with Fluent). 实际上我们同时使用Linq和NHibernate(使用Fluent)。 If you have a little patience with the learning curve, then you will quickly fall in love. 如果你对学习曲线有一点耐心,那么你很快会坠入爱河。

LINQ is just a set of new C# features: extension methods, lambda expressions, object initializers, anonymous types, etc. LINQ只是一组新的C#特性:扩展方法,lambda表达式,对象初始化器,匿名类型等。

"LINQ to SQL" on the other hand is something you can compare other SQL wrappers. 另一方面,“LINQ to SQL”可以比较其他SQL包装器。

NHibernate and Linq To Sql are Object/Relational Mappers designed to ease dealing with the impedence mismatch found between objects and RDBMS. NHibernate和Linq To Sql是对象/关系映射器,旨在简化处理对象和RDBMS之间发现的阻塞不匹配。 If you where want to achieve a testable, persistant ignorant application, NHibernate is the way to go. 如果你想要实现一个可测试的,持久的无知应用程序,NHibernate是要走的路。 I would always recommend NHibernate over Linq To Sql. 我总是会推荐NHibernate而不是Linq To Sql。 Both tools are aimed at removing dealing with data access. 这两个工具旨在消除处理数据访问。 How many times do you really need to write data access code? 你真的需要多少次写数据访问代码?

Castle is an application framework and Inversion of Control container and doesn't provide data access. Castle是一个应用程序框架和Inversion of Control容器,不提供数据访问。 It supplies facilities for using NHibernate, making for less friction, and it also supplies an implemenation of the Actuve Record pattern using NHibernate. 它提供了使用NHibernate的设备,减少了摩擦,并且还使用NHibernate提供了Actuve Record模式的实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM