DCSIMG
Tools: Linq Extensions - עומר.נט

Browse by Tags

All Tags » Tools: Linq Extensions (RSS)

Extension Methods Roundup: Intersect, Union, AsNullable and GroupEvery

Posted Aug 01 2008, 12:51 AM by עומר ון קלוטן  

Here we go with the third installment of the Extension Method Roundup. The reason behind these 'code dumps' is that LINQ is a central part of my coding and always find new problems I want to find elegant solutions to. Hope these prove as useful to you as they do to me. Intersect / Union Again...

Asynchronously Preloaded LINQ Queries

Posted Jul 29 2008, 11:04 PM by עומר ון קלוטן  

As a rule of thumb, when presented with two independent blocking I/O operations on more than one independent devices, it's best to use threads to create parallel operations, instead of waiting for a single synchronous operation to complete. That way, executing operations O 1 , ..., O n , each of...

Extension Methods Roundup: Remove, Aggregate, At, AsIndexed and Friends

Posted Jun 19 2008, 10:28 PM by עומר ון קלוטן  

Hey hey hey! It's time for another Extension Methods Roundup! Here are some of the extension methods I've written since the last one: Dictionary's Missing Remove Methods public static void Remove<TKey, TValue>( this IDictionary <TKey, TValue> dictionary, TValue value) { // Check...

Extension Methods Roundup: IndicesWhere, TakeEvery, Distinct

Posted May 18 2008, 04:14 PM by עומר ון קלוטן  

As I do from time to time, here is a batch of three Extension Methods I've written recently: IndicesWhere /// <summary> /// Gets the indices where the predicate is true. /// </summary> public static IEnumerable < int > IndicesWhere<T>( this IEnumerable <T> enumeration...

Linq: FirstOrFallback

Posted Apr 23 2008, 01:44 PM by עומר ון קלוטן  

Sometimes you want to use FirstOrDefault , but the default value of T is a valid value that might get returned. If you used FirstOrDefault , you wouldn't know whether the value that you got is a valid first or the default fallback. I use FirstOrFallback to explicitly specify which fallback value...

Linq Extensions Release 2 Now on CodePlex

Posted Apr 23 2008, 10:29 AM by עומר ון קלוטן  

I've updated my long standing Linq Extensions project on CodePlex to .NET 3.5 RTM and added the latest extension methods. You can open bugs and feature requests using the Issue Tracker . If you want to download it, go and download the source code directly . [Cross-Posted from Omer van Kloeten's...

Linq: The Missing ToDictionary Extension Method Overload

Posted Apr 22 2008, 04:20 PM by עומר ון קלוטן  

Enumerating over a Dictionary<TKey, TValue> you will get structs of type KeyValuePair<TKey, TValue> . Whenever you use the ToDictionary extension method, you are forced to specify how to get the key and value for each item, even if it's an enumeration of KeyValuePair s. Seems a bit redundant...

Linq: SequenceSuperset

Posted Apr 22 2008, 03:46 PM by עומר ון קלוטן  

Here's another Linq method I wanted to share. This one takes two enumerations, enumeration and subset and checks to see whether subset exists in enumeration in its original order. I used the naming convention set by SequenceEqual . Examples: enumeration = (1, 2, 3, 4, 5); subset = (3, 4) ==> SequenceSuperset...

Linq: ContainsAtLeast and AggregationOrDefault

Posted Apr 06 2008, 08:51 AM by עומר ון קלוטן  

I've created a couple of useful extension methods that I like to use with Linq, so here they are: ContainsAtLeast I've noticed that there's no way to find out whether a collection has at least X items. The following takes the collection, tries to take X items from it and asks whether it succeeded...