Tag: LINQ
Code Review: FirstOrDefault()
I regularly review the code that I maintain. Recently, I've come across code like this fairly often: someCollection.FirstOrDefault().Id I cannot rightly...
LINQ: FirstOrDefault without the null check afterwards.
So, I was considering a problem I had that called for a LINQ statement that contains a FirstOrDefault() call. If there was an object returned I wanted a string...
First(OrDefault) Vs. Single(OrDefault)
There are two mechanisms (each with an …OrDefault variant) in LINQ for getting one item out of an enumeration. They are First and Single . There is a...
Why should you be returning an IEnumerable
I've seen in many places where a method returns a List<T> (or IList<T> ) when it appears that it may not actually really be required, or even desirable when...
Parallelisation Talk Examples – Basic PLINQ
These are some code examples from my introductory talk on Parallelisation showing the difference between a standard sequential LINQ query and its parallel...
Building a tag cloud with LINQ
I have a set of blog posts that I’m representing as a List of BlogPost objects. A BlogPost is class I created that represents everything to do with a blog...
Monitoring change in XML data (LINQ to XML series - Part 5)
This is the 5th part in a series on LINQ to XML. In this instalment we will look at monitoring changes in XML data in the XML classes added to .NET 3.5. The...
Navigating XML (LINQ to XML series - part 4)
In my last few posts on LINQ to XML ( part 1 , part 2 and part 3 ) I've shown you a starter on navigating around XML data. In this post I'll continue to show...
Navigating XML (LINQ to XML series - Part 3)
In my last two posts I've been introducing you to the the new XML classes in .NET 3.5. In this post I'll continue that and show you some...
Fizz-Buzz in LINQ
This just occurred to me. It is somewhat pointless, but I thought it was interesting: static void Main( string [] args) { var result = from say in Enumerable...
Getting values out of XML in .NET 3.5 (LINQ to XML series part 2)
In my last post I gave a brief introduction to some of the new XML classes available in .NET 3.5. In this post I'll continue that introduction by explaining...
Introduction to LINQ to XML
Last year I wrote about the new languages features available in C# 3.0 ( Anonymous Types , Extension Methods , Automatic Properties , A start on LINQ , Object...
A start on LINQ
I was at the Microsoft MSDN Roadshow today and I got to see some of the latest technologies being demonstrated for the first time and I'm impressed. Daniel...
