Skip to main content
.NETCoreApp3.1net6.0net7.0net8.0

This project enhances LINQ to Objects with the following methods: AggregateRight, AssertCount, AtLeast, AtMost, Cartesian, Choose, CountBetween, CollectionEqual, CompareCount, CountBy, CountDown, Consume, DenseRank, DenseRankBy, DistinctBy, ElementAt (pre-.NET 6.0), EndsWith, EquiZip, Evaluate, Exactly, ExceptBy, Exclude, FallbackIfEmpty, FillBackward, FillForward, Flatten, Fold, From, FullGroupJoin, FullJoin, Generate, GenerateByIndex, GetShortestPath, GetShortestPathCost, GetShortestPaths, GroupAdjacent, Index, IndexBy, Insert, Interleave, Lag, Lead, LeftJoin, Move, OrderBy, OrderedMerge, Pad, PadStart, PartialSort, PartialSortBy, Partition, Permutations, Pipe, PreScan, Random, RandomDouble, RandomSubset, Rank, RankBy, Return, RightJoin, RunLengthEncode, ScanBy, ScanRight, Segment, Sequence, Shuffle, SkipUntil, Slice, SortedMerge, SortedMergeDescending, Split, StartsWith, Subsets, TagFirstLast, Take (pre-.NET 6.0), TakeEvery, TakeUntil, ThenBy, ToArrayByIndex, ToDataTable, ToDelimitedString, ToDictionary, ToLookup, Trace, Transpose, TraverseBreadthFirst, TraverseDepthFirst, TrySingle, Unfold, Where, Window, WindowLeft, WindowRight, ZipLongest, ZipMap, ZipShortest

Published
Nov 27, 2023
2y ago
Total Downloads
257.5K
257,532

Install

dotnet add package SuperLinq --version 5.4.0
ProductVersions
.NET
net6.0net7.0net8.0
Other
.NETCoreApp3.1

README

SuperLinq

LINQ to Objects is missing a few desirable features.

This project enhances LINQ to Objects with extra methods, in a manner which keeps to the spirit of LINQ.

SuperLinq is available for download and installation as NuGet packages.

Usage

SuperLinq can be used in one of two ways. The simplest is to just import the SuperLinq namespace and all extension methods become instantly available for you to use on the types they extend (typically some instantiation of IEnumerable<T>).

Apart from extension methods, SuperLinq also offers regular static method that generate (instead of operating on) sequences, like Unfold, Random, Sequence and others.

Migration from MoreLINQ

In most case, migration should be easy:

  1. Remove the nuget reference to MoreLINQ and add a reference to SuperLinq.
  2. Replace any using MoreLinq; with using SuperLinq;
  3. Remove any using MoreLinq.Extensions.*

This is because SuperLinq has been updated to be side-by-side compatible with .NET Core 3.1 and .NET 5.0/6.0.

Breaking Changes

Framework Support

Support for earlier frameworks has been dropped. The earliest version supported by SuperLinq is .NET Core 3.1.

Acquire

Acquire has been removed. It was used internally to support other operators, but improved data structures have been introduced to better support them.

AwaitQuery/Observable/Experimental Operators

These operators have been removed, as they do not fit the model of the other SuperLinq operators.

Backsert

This method has been obsoleted in favor of a new overload for .Insert() that receives an Index parameter, which covers the same behavior.

CountDown

An additional overload has been added that returns a stream of (TSource item, int? count).

FullJoin

This method has been obsoleted in favor of a new method .FullOuterJoin(), which has more options and capabilities.

Lag/Lead

Additional overloads have been added for Lag/Lead that return streams of (TSource cur, TSource lag/lead).

LeftJoin

This method has been obsoleted in favor of a new method .LeftOuterJoin(), which has more options and capabilities.

OrderedMerge

This method has been obsoleted in favor of a new method .FullOuterJoin(), which has more options and capabilities.

Pairwise

Pairwise has been removed as it overlaps behavior with both .Lag() and .Window()

PartialSort

The sorting behavior of .PartialSort() has been changed slightly, as it now uses a stable sorting algorithm. This means that items that have the same value (or key) will return in the same order that they were originally encountered in the stream. This is a minor change from old sorting behavior.

Rank

The behavior and return type of Rank has been updated:

  • Previously, Rank would rank according the highest value by default, opposite to the sorting.
    • Now, Rank ranks according to the lowest value, matching the sorting
  • Previously, Rank would return a simple list of integers matching the original items
    • Now, Rank returns a sorted list of items with their rank
  • Previously, Rank would rank each group with a sequential rank value
    • Now, Rank ranks each group according to how many total items have been encountered in the stream thus far.
    • DenseRank will rank each group with a seqential value.

All of these changes are made to bring Rank/DenseRank with the behavior expressed for Rank/DenseRank in SQL systems (Sql Server, PostgreSQL, etc.)

RightJoin

This method has been obsoleted in favor of a new method .RightOuterJoin(), which has more options and capabilities.

RunLengthEncode

The return type has been changed from a stream of KeyValuePair<T, int> to a stream of (T value, int count)

.NET Versions

Base library is supported on .NET Core 3.1 and .NET 5.0+.

Documentation

Detailed documentation on the operators is available here.

Changes from Previous Version

No structural changes between v5.4.0-preview.1 and v5.4.0.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

Compatibility metadata lists 4 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.