Problem solve Get help with specific problems with your technologies, process and projects.

Beginning LINQ development, Part 3

LINQ works well for managed code and for RAD, but the language enhancements it brings to the .NET Framework should be considered carefully.

Previous iterations of our Beginning LINQ development tips offered links to tutorials, videos and other resources for getting started with the Language Integrated Query in Visual Studio 2008.

Here we actually do our own work and report on what two .NET development experts had to say about LINQ in recent Boston area appearances. Taken together, the two talks suggest that the Language Integrated Query provides a powerful syntax for managed code but that, at the same time, the language enhancements it brings to the .NET Framework 3.5 should not be used without hesitation.

More on LINQ development
Beginning LINQ development, Part 1

Beginning LINQ development, Part 2

"LINQ will change how you write managed code"

For Richard Hale Shaw, president of the Richard Hale Shaw Group, LINQ represents the latest progression in the .NET Framework's mission to bring together the client, business logic and data tiers. This, though, is no mere step -- it's a leap.

"You can apply the mechanisms of LINQ to almost any aspect of day-to-day programming using managed code," Shaw said in a session on data-driven Web application development at ReMIX07 Boston. "I think it'll change the code you write to almost a revolutionary perspective."

LINQ's strength comes from a number of complementary features. Its queries work with all managed code languages in the .NET Framework. These queries are structured like TSQL, but, since the From statement comes first, the query sets off IntelliSense. Moreover, by leveraging IEnumerable , LINQ works with any data with origins in the iterator.

Overall, Shaw said, LINQ statements are "lightweight and simpler to use than typed datasets, and they are better suited for data updates." The overhead, he added, is no moreso than if a programmer wrote his own For or ForEach loops at runtime.

"All these things I urge you to use with caution"

Shawn Wildermuth, president of Wildermuth Consulting Services, LLC, agrees that LINQ offers an healthy alternative to ForEach statements and that its support for numerous data types, from the well-advertised SQL and XML to Flickr and Amazon, provides a level of homogeneity previously unseen.

However, Wildermuth told the New England Visual Basic Professionals User Group, LINQ is just another tool in the toolbox. "This isn't going to change the way people develop. It's not going to force people to rearchitect solutions," he said. "A lot of this is performance characteristics versus labor and ease of use."

Expanding on the latter point, Wildermuth noted that, while LINQ works well for RAD projects and does make code cleaner, it may not be ideal for large deployments. "With LINQ, a lot of code runs at compile time," he said. "Just because it's LINQ doesn't mean it's going to go faster."

Wildermuth also preached caution regarding use of some of the language features Microsoft introduced to Visual Basic 2008 and C# 3.0 in order to accommodate LINQ.

More on extension methods in the .NET Framework 3.5
Extension methods in VB 2008

Extension methods in C# 3.0

Variable inferences, for example, let programmers define a type without known the type, while extension methods let programmers define classes on methods they do not own, which could be very confusing, particularly during debugging, he said.

Two other .NET Framework 3.5 features -- anonymous types, which are ad hoc definitions of types and properties, and lambda functions, which are shortcuts for anonymous delegates -- are more useful, but it will take developers some time to get used to them, Wildermuth said.

Back to basics

We end with the latest article to provide a concise introduction to LINQ. It's called Learn the Basics of LINQ, and is provides some thoughts on using extension methods and lambda expressions for those who opt to take the plunge.

This was last published in October 2007

Dig Deeper on Visual Studio 2008 and Language Integrated Query (LINQ)

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

TheServerSide.com

SearchCloudApplications

Close