Manipulating Objects in a Collection with LINQ
I was chatting with a co-worker about using LINQ to replace for-each loops. More specifically, we were discussing how to modify the properties of items in a collection or a subset of the collection. I...
View ArticleMaking Enumerable Collections LINQ-Queryable
LINQ is one of the greatest things that’s happened to Windows programming. I love it, and I use it all the time. Occasionally, you’ll run into an enumerable collection class that can’t be queried with...
View ArticleAdd Additional References in LINQPad
LINQPad is one of my favorite development tools. I use it all the time to do quick tests to verify thoughts or discussions that I’m having with peers. It’s terrific for building snippets for email and...
View ArticleJoins in LINQ
The scenario: you have two related collections of objects, and you need to smush ‘em together into a collection of combined records. It’s easy to do with LINQ’s Join method, but Join can seem a little...
View ArticleCollection Lookups
Yesterday, I was discussing a method with a co-worker where I suggested we loop through a collection of records and, for each record, do another retrieval-by-ID via LINQ. He brought up that this would...
View ArticleFind Duplicate Database Entries with LINQPad
A co-worker and I were chatting about a code problem he was having that was likely due to duplicate entries in a database table. He thought that records in the table were unique based on two columns,...
View ArticleGroup Strings Using LINQ and Regular Expressions
I was working on a problem yesterday where I needed to combine strings that were the same except for one part. Here’s a simplified version of the problem: Input Array: "Adam likes apples." "Adam likes...
View ArticleSimple .DistinctBy Extension
LINQ’s Distinct extension has largely been a disappointment to me. Sure, it’s nice when I’m working with a collection of integers, but more often than not, I’m working with a collection of objects and...
View Article