2

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?

EEE
  • 4,536
  • 3
  • 28
  • 34
  • Don't forget about Linq to nHibernate: http://ayende.com/Blog/archive/2009/07/26/nhibernate-linq-1.0-released.aspx – tvanfosson Nov 14 '09 at 13:44
  • WHS - the detail of the question is clear but you need to change the title. – Murph Nov 14 '09 at 15:28
  • Remember that Linq to SQL supports *MSSQL ONLY*. – UpTheCreek Nov 14 '09 at 15:31
  • There are some previous SO posts that may help you: - [http://stackoverflow.com/questions/26971/nhibernate-vs-linq-to-sql](http://stackoverflow.com/questions/26971/nhibernate-vs-linq-to-sql) - [http://stackoverflow.com/questions/53417/nhibernate-or-linq-to-sql](http://stackoverflow.com/questions/53417/nhibernate-or-linq-to-sql) and also some about Nhibernate to Linq: [http://stackoverflow.com/questions/624609/linq-to-nhibernate](http://stackoverflow.com/questions/624609/linq-to-nhibernate) – Kb. Nov 14 '09 at 13:59

6 Answers6

4

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
  • 11,998
  • 1
  • 34
  • 57
  • Can you point to an article or post the reasons you want to avoid LINQ-to-Entities? – kenny Nov 14 '09 at 14:19
  • 2
    Check out: http://efvote.wufoo.com/forms/ado-net-entity-framework-vote-of-no-confidence – Wim Nov 14 '09 at 14:31
1

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)

Hannoun Yassir
  • 20,583
  • 23
  • 77
  • 112
1

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
  • 305,152
  • 44
  • 369
  • 561
1

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 Molina
  • 19,158
  • 26
  • 98
  • 163
1

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
  • 20,853
  • 18
  • 75
  • 116
0

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
  • 15,108
  • 7
  • 50
  • 91
  • 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 Nov 14 '09 at 16:48
  • 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.aspx Here'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-40 The focus is on EF, period. – IrishChieftain Nov 14 '09 at 20:18
  • @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 Nov 15 '09 at 12:11