Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Linq to SQL still a viable choice for developing applications?

I'm reading up on .NET things again after a brief (and occasionally ongoing) stint with Ruby on Rails. I'm wondering if LINQ is still a choice when choosing an ORM for new applications, or if I should learn something like NHibernate instead which seems to still be going strong. I know that Linq has basically been subsumed by the Entity Framework, but when I tried EF (this was a while ago) I found it far too heavy and too "mouse-driven" (i.e. a lot of playing around with a designer). I've watched a few short screencasts on NHibernate and I do like the separation of concerns that it enforces as well as the idea that your Model can be kept clean.

Linq's syntax is pretty nice though, but it's not a true ORM and I don't want to look at learning something that's basically obsolete when I can learn something that's being used or will be used (EF and/or NHibernate, for example).

So, is Linq still something that should be considered using in an application (let's assume something of moderate complexity; not a trivial application, but not a huge undertaking; around as complex as a web-based application like 37Signal's Highrise) or is there something better that's worth looking at instead?

like image 259
Wayne Molina Avatar asked Dec 03 '25 00:12

Wayne Molina


1 Answers

Linq is not an ORM and Linq is great. You very likely want to use Linq if at all possible.

LinqToSql is an ORM, although it is very light feature wise. It gives you basic (and primarily one time) code generation of active record type data layer classes based on a SQL Server database definition. While it supports some basic ORM features, most anything else you want, you are going to have to create yourself.

EntityFramework is also an ORM. While it shares some of LinqToSql's limitations, it also does some things better and some things worse. The current V1 has many limitations, some of which will be addressed in the next version (V4) that comes out with Visual Studio 2010.

Neither LinqToSql or EntityFramework are mature, proven ORMs. Both have significant drawbacks that you are likely to run into doing most "normal" software development projects.

NHibernate offers significantly more features than either of Microsoft's ORMs and you'll find that it works in pretty much any "real world" situation. If you like the ActiveRecord pattern followed by Microsoft's ORMs, NHibernate supports that as well with Castle ActiveRecord.

All three of these ORMs support Linq.

One word of caution. It can be difficult and expensive to switch ORMs mid-project, depending on how well you separate your data layer from your other layers. You can't easily start with, for example, LinqToSql and then switch to, for example, NHibernate later when you run into one of LinqToSql's many limitations unless you are really smart about how you decouple your ORM from the rest of your implementation, which can be very difficult depending on the ORM.

like image 124
Michael Maddox Avatar answered Dec 05 '25 15:12

Michael Maddox



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!