LiNQ to SQL Introduction

I finally got around to installing Visual Studio Orcas Beta 2 again. Recently I wanted to start looking into making use of O/RM (Object relational mapping) for a private project I was starting up at home.

First I tried to install NHibernate and use that but since I was too lazy to figure out exactly how it worked I moved onto ActiveRecord. That was going well till I actually tried to run the damn project. ActiveRecord for some reason would not connect to my database. After checking everything and posting on the ActiveRecord forums nothing was resolved. It is strange though as the connectionstring ActiveRecord was using was being used for a standard SqlConnection which worked perfectly.

I have no decided to move my focus from third party “plug-ins” to a Microsoft Beta. For those of you have no heard of or read about LINQ then take a seat and get ready.

LiNQ (Language Integrated Query)


The LINQ Project is a codename for a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations. It extends C# and Visual Basic with native language syntax for queries and provides class libraries to take advantage of these capabilities.

http://msdn2.microsoft.com/en-us/netframework/aa904594.aspx


The LiNQ project covers several areas each naturally has a different function:

If you don’t have Orcas Beta 2 yet you can download it here : http://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx. Now I realise its quite a massive download so if you want me to copy it to DVDs for you then drop me a mail here at “StevenMcd at StevenMcD.Net” and we’ll work something out to get these DVDs to you.

LiNQ to SQL

LiNQ to SQL is what I’m doing to be concentrating on first since this is basically and O/RM as previously stated. An amazing set of tutorials are available from ScottGu’s blog located here. His tutorials on LiNQ to SQL start here. His blog is wealth of information and if your aren’t subscribed to his RSS feed you are seriously missing out! Now what do I mean by saying that LiNQ is an O/RM? Imagine spending more time designing your classes to reflect your database structure? So take for an example an Employee Class. You would have an Employee Name, LastName, and probably ID Number. Imagine not having to write the general Select, Insert, Update and Delete SQL statements that makes our jobs so tedious?! Well imagine no more!

By constructing your class properly, and using a set of LiNQ attributes on your classes and properties you would not have to write these boring and tedious tasks! Obviously with more complex queries to the database you would still need to write your own Stored Procedures. In a future article I will cover this topic in more detail but for now I’ll end this off. I hope to have my next LiNQ article up by the weekend but due to other commitments it might only be early next week. For now, check out Scott’s blog and at the links listed below!

LINQ: .NET Language-Integrated Query
101 LiNQ Samples
LiNQ Wikipedia Entry

Blogged with Flock

Posted under Development, LiNQ by StevenMcD on Tuesday 25 September 2007 at 7:08 pm

2 Comments »

  1. Comment by Jameel — September 26, 2007 @ 6:00 am

    Have you tried using llblgen pro , granted its not free but the application works wonders . Have been using it for a while and must say the work they put into it really shows

  2. Comment by StevenMcD — September 30, 2007 @ 6:32 am

    Hi Jameel,

    I haven’t tried it. Unfortunately if its not free I doubt I’ll get to try it :(

RSS feed for comments on this post. TrackBack URI

Leave a comment