Summary

As you can see, Microsoft's C# team has been busy adding enhancements to C#. All of the C# enhancements discussed in this chapter have been made specifically for LINQ. But even without LINQ, there is a lot to be gained from the new C# features.

The new object and collection initialization expressions are a godsend. Stubbing in static, sample, or test data is much easier than before, significantly reducing the lines of code needed to create the data. This feature combined with the new var keyword and anonymous types makes it much easier to create data and data types on the fly.

Extension methods now make it possible to add functionality to objects, such as sealed classes or perhaps classes for which you don't even have the source code, which just wasn't possible before.

Lambda expressions allow for concise specification of functionality. While not eliminating the need for anonymous methods, they add to the arsenal of ways to specify simple functionality, and I like the brevity of the syntax. While you may initially be put off by them, I think with time and experience you will grow to appreciate them, too.

Expression trees provide third-party vendors wanting to make their proprietary data stores support LINQ with the ability to provide first-class performance.

Partial methods offer a very lightweight event-handling mechanism. Microsoft will leverage this in its LINQ to SQL entity class generation tools so that you can hook into the entity classes at key points in time.

Finally, query expressions provide that warm fuzzy feeling when first seeing a LINQ query that makes you want to get on board with LINQ. Nothing makes a developer analyzing a new technology feel comfortable quicker than technology resembling a familiar and proven technology. By giving LINQ queries the ability to resemble SQL queries, Microsoft has made LINQ compelling to learn.

While all of these language enhancements by themselves are nice features, together they form the foundation for LINQ. I believe that LINQ will be the next SQL or object-oriented bandwagon, and most .NET developers will want LINQ on their résumé. I know it's going to be on mine.

Now that I have covered what LINQ is and what new C# features and syntax it requires, it's time to get to the nitty-gritty. Please don't allow my technical jargon—nitty-gritty—to intimidate you. The next stop is learning about performing LINQ queries on in-memory data collections such as arrays, ArrayLists, and all of the new C# 2.0 generic collections. In Part 2 you will find a bevy of functions to supplement your queries. This portion of LINQ is known as LINQ to Objects.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset