Aline’s Tech Blog

All my geekness is here :-)

First steps with LINQ December 4, 2008

Last week, I had to think about LINQ for my project at work, and I discovered all the power of this framework. I didn’t go further than a very basic sample demo. Here are my first thoughts about this technology, after only a few hours surfing the net and trying a little things. (forgive me for my mistakes and lack of experience, though.)

A powerful Database-to-classes mapper

Several possibilities:

  1. You are using an existing database or you prefer designing your database before your object model: Create a new SQL connection in Visual Studio 2008 and drag-n-drop your database in a new DBML file… That’s all, everything is done and you can manipulate objects.
  2. You are starting a new project… you will work with only 1 model / diagram: the DBML file.

Something which could be useful if you want to create a database from the DBML : The db.CreateDatabase() feature. But be careful, as he says.

An easy and secure way to query data

Here you cannot forget a string query somewhere. You write your query using visual studio Intellisense, you cannot make mistakes…

Easy to use, fast, smart… magic!

In 5 minutes the mapping, the data abstraction is done. So easy. Nothing else to do. I think if I was designing a new project now, I would not hesitate.

LINQ allows anyone to have a good structure in his application by creating an adaptable data access layer.

Limits

Full-Microsoft… Again

What I only found about LINQ was LINQ to SQL (understand MS SQL SERVER) and LINQ to XML. Nothing for other database management systems for the moment.

Not serializable

This can look like a minor problem, but the LINQ tables and data is not serializable. And then, no .NET remoting with LINQ! But of course, the new .NET 3.5 WCF framework works with it.

I’d like to make further topics about LINQ. Probably 1 sample demo explained, and LINQ vs NHibernate.