开发者

Does Linq Remove The Need For Hibernate?

Just wondering whether anyone wi开发者_StackOverflow社区ll still use Hibernate once they move to C# 3

Are these mutually exclusive??


It's important to note that Linq is not just an ORM tool. There is also Linq-To-XML and Linq-To-Objects to name two but there are more. Linq is a set of language extensions to C# and VB that give you syntactic sugar when dealing with object collections.

As to your main question, Linq-to-SQL is fine if you have a one-to-one mapping from tables to domain objects. Where NHibernate comes into it's own is where you have an existing complex domain model or existing complex database schema and you want to map between them.

Additionally, it's possible to use both with Linq-To-NHibernate.


Linq is more about making a uniform way in which one can query DB, XML, Objects or any custom data store. Hibernate is only for querying DBs. You can use Hibernate instead of Linq-to-SQL in case you are more proficient and comfortable in that Linq provides pretty much the same powerful ways to query DB as Hibernate. So in a way when restricting our discussion to DB, Linq can serve you the same (or a large majority of!) purpose as Hibernate.


I think more people would use NHibernate if it could compete with Hibernate. That being said, NHibernate is generally not needed in a .net shop.


The existance of Linq To NHibernate alone, proves not.


Your terminology is off. LINQ is just syntactic sugar for manipulating data. Linq to Sql is probably what you're talking about.

IIRC Linq to Sql only supports MSSql (apparently they intentionally killed off compatability with other db providers, I have no idea why, some speculate anti-competition, others state a deadline turned up so they just culled what wasn't ready). So no chance of NHibernate being irrelevant here.
The Entity Framework (MS's ORM tool that supports all databases). When this initially came out some of the ORM community hated it, it didn't support "persistence ignorance" and a number of features, concepts and premises the community expects from a modern ORM. I believe they are working to improve it but they have a lot of catching up to do to get close to NHibernate IMO.

So no, NHibernate is still massively relevant if you want fine control over your ORM. It is one of the most flexible yet complex ORMs about and therefore still has its place.


I dont like linq-to-sql (since that is what you mean) that much since you have to design a database schema. With hibernate (although i use a similar product named XPO) you just make your objects and the framework takes care of the relations (one-to-one, many-to-one, M-To-M).

THat is the big disadvantage of linq to sql. So no, they're not mutually exclusive.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜