1. Home
  2. Computing & Technology
  3. Visual Basic
Dan Mabbutt
Dan's Visual Basic Blog

By Dan Mabbutt, About.com Guide to Visual Basic

LINQ Queries - An Example Driven Introduction

Friday October 16, 2009

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 says:

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 says:

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>

Explore Visual Basic
By Category
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic

©2009 About.com, a part of The New York Times Company.

All rights reserved.