LINQ
Back to TOCJust VideosCondensed TOC
Language Integrated Query
- The GroupAdjacent Extension Method
- How to Create Hierarchy from Flat Data using LINQ
- Are Developers Using LINQ?
- Are Developers Using LINQ? (Part 2)
- Chunking a Collection into Groups of Three
- Use a Lambda Expression for an Event Handler
- Find Duplicates using LINQ
- Closures
- LINQ to TEXT and LINQ to CSV
- Formatting LINQ Code
- Anders Hejlsberg Introduces C# 4.0 at PDC 2008
- Debugging LINQ Queries
- The SkipLast Extension Method
- Why I Don’t Use the ForEach Extension Method
- Rollup Extension Method: Create Running Totals using LINQ to Objects
- Ad-Hoc String Concatenation using LINQ
- Hex Dump using LINQ (in 7 Lines of Code)
- Simulating Virtual Extension Methods
- Screen-Cast: Functional Programming Utility Methods and Classes for Open XML
This post introduces a GroupAdjacent generic extension method that groups elements in a collection with adjacent elements based on a common key. (Article)
Sometimes you have flat data where there is hierarchy expressed in the data, but the form of the data is flat. You may need to transform this data into a hierarchy, such as an XML tree. (Article)
I had an interesting conversation with my nephew the other day. He is a very bright CS student working as a summer intern at a software company (not Microsoft). He is programming in C# using Visual Studio 2008. I asked him if developers at his company were using LINQ, and he said, “No, that the folks in charge had basically forbidden it, because no one understands it.” (Article)
There are four basic scenarios where developers use LINQ. (Article)
Sometimes you need to group a collection into a set of groups, each with n members. (Article)
You can use lambda expressions to write an event handler, even for classes that predate C# 3.0 and the latest version of the framework. This can shorten your code, and make it easier to read. (Article)
Sometimes you need to find the duplicates in a list. (Article)
Closures are one of the key components in C# 3.0 that makes functional programming easy, and results in clean syntax. (Article)
LINQ is a great tool for writing ad-hoc queries and transforms, and occasionally I need to write queries or transforms on text files. (Article)
Over time, I’ve adjusted my code formatting style – changing the white space that I insert, or where I place the parentheses. In this post, I detail some aspects of my current code formatting approach, focusing only on formatting LINQ queries that are written in the ‘method syntax’, not using LINQ query expressions (from — select —). (Article)
Anders Hejlsberg presented a fascinating and entertaining session at PDC 2008 on C# 4.0. He talked about dynamic typing, optional and named parameters, improved COM interoperability, and improved support for co-variance and contra-variance. These language improvements are very cool – they enable us to write code that more closely expresses our intent, with less syntactic noise. (Article)
Debugging LINQ queries can be problematic. One of the reasons is that quite often, you write a large query as a single expression, and you can’t set a breakpoint mid-expression. Writing large queries in expression context is particularly powerful when using functional construction to form XML (or using the strongly typed DOM in Open XML SDK V2). This post presents a little trick that makes it easier to use the debugger with LINQ queries that are written using ‘method syntax’. (Article)
When writing queries, just as you sometimes want to skip the first n items in a collection, on occasion you want to skip the last n items. You could certain count the items remaining in the collection, and use the Take operator to take all but the last, but this would mean iterating the collection twice, and would result in uglier code. (Article)
In my first version of my functional programming tutorial, I discussed a ForEach extension method, but I removed the topic from the second version. I no longer recommend using a ForEach extension method. This post explains why. (Article)
This post introduces the Rollup extension method, which enables you to write LINQ code to produce a running total. In addition, it enables you to write the equivalent of a state machine using LINQ and Functional Programming. (Article)
Presents a small idiom to concatenate a set of strings. (Article)
Presents a bit of LINQ code to do a hex dump of a byte array. (Article)
Similating virtual extension methods can help in solving problems when dealing with a class hierarchy that uses polymorphism. (Article)
In the process of developing the PowerTools for Open XML, over the years, I have developed some needed core functionality and utility methods, particularly for writing LINQ to XML code that queries and transforms Open XML documents. (Video)