tags:

views:

35

answers:

2

I come from a different language and there are always the different views about what to use and what not to use. What is your opinion and pros and cons on why to use or not use LINQ to SQL?

Also I saw there was a LINQ to NHibernate is this worth using if you have NHibernate?

I have not gotten NHibernate installed just yet.

Thanks

A: 

This is very hard to answer, without knowing what you want to build with it.

For small scale projects, it is my experience that you can get up-and-running with LINQ-to-SQL very easily, and it is easy to work with. It does however, lack some features (such as inheritance, I believe). Also, Microsoft has discontinued further development of LINQ-to-SQL.

The current ORM / Persistence Framework from Microsoft is Entity Framework 4. It is being actively developed by MS; it has more features than LINQ-to-SQL, and is being branded as being a better fit for enterprise scale applications. With EF4, you can use LINQ expressions in your queries, as you can with LINQ-to-SQL.

Another option is NHibernate, which I use for my current project, and in my experience, it is a bit of both worlds. It might be of some value to you, that it is open source. It is easy to get started with, but be prepared to spend some time learning more advanced concepts. LINQ-to-NHibernate is not quite mature in the version we are using (2.x), but I think it is being much improved in 3.0. You can make some queries in LINQ, but the good thing is, that you will be able to fall back on the very powerful HQL or the Criterion API; when you need it.

In my mind, these 3 are the largest ORM contenders in the .NET world at the moment. There is also Subsonic, or Castle ActiveRecord; which I have no experience with; but they should be suited for minor projects.

With all this being said, you need to carefully consider your requirements for an ORM, test out some (write some PoC code that mimics the data-access you will be doing; see how easy it is to get set up). There is easy Yes/No answer for this.

driis
+3  A: 

I would probably not recommend using LINQ to SQL at this point. If you're doing new development, I would recommend the ADO.NET Entity Framework instead.

This is a much more current, actively developed alternative to LINQ to SQL, as it's getting a lot of attention from Microsoft moving forward.

As for LINQ to Nhibernate... If you're already planning to use Nhibernate, this gives you the benefits of LINQ. I, personally, very much like using LINQ in my projects, as I find it makes my code faster to write and more maintainable, so I'd highly recommend this. I'd probably still favor EF over Nhibernate for .NET development (it's built into the framework, supported by MS, etc), however.

Reed Copsey