views:

273

answers:

7

I want to learn ORM and I wonder which is beneficial for start up; Linq to SQL or Nhibernate. considering time,adaptation... etc

+2  A: 

If you don't have experience with ORMs Linq to SQL is slightly easier to learn than NHibernate. It also has better integration with Visual Studio.

Darin Dimitrov
@marc, that's what I wanted to say, unfortunately I didn't use the correct term, English is not my native language :-) I've updated my post. Thanks for the clarification.
Darin Dimitrov
@Darin: i was thinking you probably wanted to say that and just got the words mixed up - no problem! :-)
marc_s
A: 

Linq to SQL is supposed to be replaced by the Entity Framework; I think NHibernate would be a good choice since there are lots of references and it seems be widely used as well.

Otávio Décio
Linq-to-SQL is still officially and fully supported in .NET 4 / VS 2010 - no reason to give it up
marc_s
@marc - the writing on the wall is clear enough for me.
Otávio Décio
Again - sure that makes good sense if you're betting your whole company on that strategy - but for a beginner, Linq-to-SQL is *MUCH* easier to learn and understand than EF. Not saying EF is bad.... just more involved and complex and too much if you're just beginning....
marc_s
LINQ to SQL is absolutely still alive. Even if EF is the preferred data access technology in the future, LINQ to SQL isn't going away --it's in the framework. We're drifting slightly off topic, but I wouldn't agree that EF is substantially more difficult than LINQ to SQL (especially 4.0). I realize the initial release had a number of short comings, but I don't think it was as bad as people made it out to be. I'm very excited about the 4.0 release. I've been playing around with it and I really like the direction MS took.
senfo
A: 

In addition to Darin answer, Consider this post i read earlier.

Linq to SQL is easier and faster to implement and integrate quickly, but Nhibernate can give you more flexibility if you need more control. Recently, i had to decide if i was to use Linq to SQL on my new app project - i just didn't like the lack of flexibility.

http://stackoverflow.com/questions/26971/nhibernate-vs-linq-to-sql http://www.acceptedeclectic.com/2007/12/linq-to-sql-vs-nhibernate-part-1-what.html

Let me know if it helps.

Colour Blend
+3  A: 

I'd go with NHibernate, because there's a nice open source community out there that supports it, answers questions on it, and so on. As your product gets bigger and more complicated, you'll appreciate the power and flexibility of NH. Finally, Linq-to-sql isn't in MS's long term plans, since they want you to use the Entity Framework, so you might end up with a dead-end technology there.

Isaac Cambron
Linq-to-SQL is still officially and fully supported in .NET 4 / VS 2010 - no reason to give it up
marc_s
+7  A: 

One important question to ask yourself is if you can accept a dependency on SQL Server. Will the database backend change to Oracle, for example? LINQ to SQL is strongly coupled to SQL Server, whereas NHibernate isn't. I'm not saying that this is necessarily a bad limitation, but it's important to consider.

NHibernate has really come a long way in the past few years. I really like Fluent NHibernate, for example, but that's not to say that LINQ to SQL is limiting. I love the integration with Visual Studio and it has proved itself more than capable of handling consistent load (Stack Overflow uses LINQ to SQL, for example).

Contrary to popular belief, LINQ to SQL is not dead.

Edit: Another important question to ask yourself is if you want to change the domain model. LINQ to SQL maps objects directly to tables. NHibernate, on the other hand, allows for a layer of indirection. This is also true of Entity Framework, by the way.

senfo
Yes, that makes sense - for an serious enterprise developer. The OP clearly states he wants to start learning - for that, I think, Linq-to-SQL with its visual designers is just much easier than NHibernate....
marc_s
I totally agree with you on the part of the visual designer.
senfo
I will use SQL server.
EEE
+2  A: 

I would put in my vote for Linq-to-SQL - why?

  • it has a visual designer which allows you to more easily and quickly get results and see something
  • NHibernate is very powerful - but that also makes it harder to learn; you have to really really love angle bracket soup (i.e. lots of XML mapping files) to get up to speed with NHibernate
marc_s
In fact, object relational designer seems hard. Where can I find good tutorials to begin with?
EEE
+1  A: 

I love Linq to SQL, it's very easy to use. Implement the repository pattern and use LINQ to SQL as your first implementation behind your repository interface. You'll find it's so easy to get a repository up quickly using the tool. You can always implement a second repository using NHibernate without breaking your app then compare your experience with the two tools.

NHibernate is "more powerful"... I guess that means you can use it against any database, and that's about it. There's a lot more to learn and if you do go that route, make sure you make full use of Fluent NHibernate to avoid all the mapping rubbish. It's much cleaner that having a bunch of XML mappings to maintain.

I find NHibernate frustrating becuase I like querying the database with LINQ and projecting (mapping) to a model . I know there is a LINQ to NHibernate floating around, but I can't say I know anyone who uses it.

Generally, I would say to use NHibernate if you are happy to get everything by ID and traverse the object model from there. As soon as you want to execute more complex queries you had best be prepared for some frustration.

Quoo