views:

468

answers:

7

Which is the best solution for 3-tier arch. Linq to SQL or Nhibernate? Specifically, I will upgrade a system in 2-tier architecture to 3-tier architecture?

Edit: And where can I find good tutorials or videos for both?

+1  A: 

if the database already exists i would go with linq to sql(generates mapping from database just by drag and drop) other ways i would chose Nhibernate(helps you generate you database based on your model)

Yassir
+3  A: 

If you're only ever need to support one DB platform and have your database model already, LINQ-to-SQL makes sense.

However, you could also use FluentNHibernate to generate the mappings for you.

If support for multiple DB's and granular and flexible control over mappings is important, go NHibernate. Else, LINQ-to-SQL will do fine. Avoid LINQ-to-Entities like the plague, for now at least (v4.0 may improve things).

Wim Hollebrandse
Can you point to an article or post the reasons you want to avoid LINQ-to-Entities?
kenny
Check out: http://efvote.wufoo.com/forms/ado-net-entity-framework-vote-of-no-confidence
Wim Hollebrandse
+1  A: 

I don't know if it's equally true for .NET, but if I were solving this problem with Java and Spring I'd start with an interface that would hide the implementation choice. Clients need not be aware of whether it's LINQ or NHibernate doing the work. Spring would allow me to inject one implementation or the other at will, without disturbing clients, as long as both implemented the agreed-upon interface.

duffymo
A: 

I haven't used Nhibernate but I do know that Microsoft has confirmed that while it will support LINQ to SQL going forward, there will be no more development done by them on that particular technology.

IrishChieftain
You might want to add a link for that "no further development" statement, I haven't seen anything that says that. For instance all the Microsoft links here say Linq to SQL will be evolved http://stackoverflow.com/questions/252683/is-linq-to-sql-doa
MarkJ
Mark, I cannot locate the link but saw a post the other where one of the MS guys came out and said it straight out. In the meantime, here's a good analysis from David Hayden:http://codebetter.com/blogs/david.hayden/archive/2008/10/31/linq-to-sql-is-dead-read-between-the-lines.aspxHere's something more recent from - observe how he keeps avoiding the question in the comments section:http://damieng.com/blog/2009/06/01/linq-to-sql-changes-in-net-40The focus is on EF, period.
IrishChieftain
@MarkJ, Microsoft has been everything except clear on their future plans and commitments to LinqToSql. My best understanding is that they will continue to support LinqToSql as long as it is part of the shipping .NET framework, but real ORM feature development going forward will be focused on EntityFramework. There is not a single clear message from Microsoft that communicates that however.
Michael Maddox
+1  A: 

I would say go with LINQ to SQL if your application needs only basic functionality, otherwise use NHibernate. I know a smattering of LINQ and I'm looking at learning NHibernate, and from what I can tell NHibernate is a better longterm solution since it's more abstract than L2S (which is pretty tightly coupled to the database), but L2S is easier to pick up and provides a quicker solution.

Without knowing more about your specific problem, I would say use NHibernate as it's more flexible and respondent to change, although with a slightly more "enterprise" learning curve than Linq to Sql. For a good NHibernate resource I recommend checking out Steve Bohlen's "Summer of NHibernate" series.

Wayne M
+1  A: 

what is the best solution for 3tier, I would say neither. There is no cookie cutter response every framework/library you choose will have trade-offs. To make this ORM decision you need to look at your business needs and determine which of the many possibilities will best help you achieve our goals in a timely and maintainable way. How complex is your domain model and can linq to sql adequately describe them.

Aaron Fischer