1. Computing & Technology

Discuss in my forum

Dan Mabbutt

LINQ Queries - An Example Driven Introduction

By , About.com GuideOctober 16, 2009

Follow me on:

LINQ - Language Integrated Query - is the reason a whole host of new technolgies were introduced in VB.NET 2008. For example, Lamda expressions and partial methods. Another technology that was introduced with LINQ is the LINQ query ... a faster and more direct way to write LINQ query expressions. This article explains it.

It would also be interesting to find out whether you find the "traditional" dot notation (object.method) or the new SQL-style query in LINQ easier to understand and use. Add your response at the end of the article.

Comments
October 17, 2009 at 4:26 am
(1) John McIlhinney :

I will often use function syntax for short expressions but query syntax tends to be more succinct so, for anything that requires more than a single function call, query syntax is often easier to read.

As someone who spends about half my time in C#, I have to admit that VB’s verbose syntax can often get in the way too. Try writing an expression that involves a couple of generic arguments and a lambda expression or two and looking at the VB code can give you a headache. Function syntax in C# can be much easier to read than function syntax in VB so, in VB, I tend to use query syntax in most cases where I can.

Function syntax gets a bit more of a workout in C# though. Query syntax in VB actually has some advantages over query syntax in C# too, like the ability to omit the Select clause if all youre are selecting is the range variable itself, and also the Distinct key word.

October 17, 2009 at 10:11 am
(2) visualbasic :

Great comment! I’m sure less experienced readers will appreciate the comparison. Since articles tend to last longer than blogs, you should add it to the reader response section at:
http://visualbasic.about.com/u/ua/usingvbnet/linqquery.htm

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

©2012 About.com. All rights reserved.

A part of The New York Times Company.