1. Bogdan Mart
  2. CollectionsQuery

Wiki

Clone wiki

CollectionsQuery / LINQ comparison matrix

This is list of LINQ(R) methods and their CQ equivalents

NameDescriptionCQ equivalent
AggregateApplies an accumulator function over a sequence.fold
AllDetermines whether all elements of a sequence satisfy a condition.all
Any<TSource>(IEnumerable<TSource>)Determines whether a sequence contains any elements.any
Any<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>)Determines whether any element of a sequence satisfies a condition.any
AsEnumerable<TSource>Returns the input typed as IEnumerable<T>.Queriable.from(...)
Average(IEnumerable<Decimal>[, Func<TSource, Decimal>])Computes the average of a sequence of Decimal values.
Cast<TResult>Casts the elements of an IEnumerable to the specified type.cast
Concat<TSource>Concatenates two sequences.concat
Contains<TSource>(IEnumerable<TSource>, TSource[,comparer])Determines whether a sequence contains a specified element by using the default equality comparer.any/contains
Count<TSource>(IEnumerable<TSource>)Returns the number of elements in a sequence.count
Count<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>)Returns a number that represents how many elements in the specified sequence satisfy a condition.count
DefaultIfEmpty<TSource>(IEnumerable<TSource>)Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the sequence is empty.
DefaultIfEmpty<TSource>(IEnumerable<TSource>, TSource)--same--
Distinct<TSource>(IEnumerable<TSource>)Returns distinct elements from a sequence by using the default equality comparer to compare values.distinct
Distinct<TSource>(IEnumerable<TSource>, IEqualityComparer<TSource>)--same--
ElementAt<TSource>Returns the element at a specified index in a sequence.at
ElementAtOrDefault<TSource>--same-- or a default value if the index is out of range.atOrDefault
Empty<TResult>Returns an empty IEnumerable<T> that has the specified type argument.empty()
Except<TSource>(IEnumerable<TSource>, IEnumerable<TSource>[,comparer])Produces the set difference of two sequences by using the default equality comparer to compare values.
First<TSource>(IEnumerable<TSource>[, predicate])Returns the first element of a sequence.first
FirstOrDefault<TSource>(IEnumerable<TSource>[, predicate])Returns the first element of a sequence, or a default value if the sequence contains no elements.firstOrDefault
GroupBy<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>)Groups the elements of a sequence according to a specified key selector function.groupToMap
GroupJoin<…>(…)Correlates the elements of two sequences based on equality of keys and groups the results. The default equality comparer is used to compare keys.
Intersect<TSource>(IEnumerable<TSource>, IEnumerable<TSource>[,comparer])Produces the set intersection of two sequences by using the default equality comparer to compare values.intersect
Join<…>(…)Correlates the elements of two sequences based on matching keys. The default equality comparer is used to compare keys.
Last<TSource>(IEnumerable<TSource>,[predicate])Returns the last element of a sequence.last
LastOrDefault<TSource>(IEnumerable<TSource>,[predicate])Returns the last element of a sequence, or a default value if the sequence contains no elements.lastOrDefault
LongCount<TSource>(IEnumerable<TSource>[,predicate])Returns an Int64 that represents the total number of elements in a sequence.---
Max<TSource>(IEnumerable<TSource>)Returns the maximum value in a generic sequence.max
Max<TSource, TResult>(IEnumerable<TSource>, Func<TSource, TResult>)Invokes a transform function on each element of a generic sequence and returns the maximum resulting value.max
Min<TSource>(IEnumerable<TSource>)Returns the minimum value in a generic sequence.min
Min<TSource, TResult>(IEnumerable<TSource>, Func<TSource, TResult>)Invokes a transform function on each element of a generic sequence and returns the minimum resulting value.min
OfType<TResult>Filters the elements of an IEnumerable based on a specified type.ofType
OrderBy<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>[,comparer])Sorts the elements of a sequence in ascending order according to a key.sort
OrderByDescending<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>[,comparer])Sorts the elements of a sequence in descending order according to a key.TODO
RangeGenerates a sequence of integral numbers within a specified range.Queriable.range
Repeat<TResult>Generates a sequence that contains one repeated value.repeat
Reverse<TSource>Inverts the order of the elements in a sequence.
Select<TSource, TResult>(IEnumerable<TSource>, Func<TSource, TResult>)Projects each element of a sequence into a new form.map
Select<TSource, TResult>(IEnumerable<TSource>, Func<TSource, Int32, TResult>)Projects each element of a sequence into a new form by incorporating the element's index.TODO
SelectMany<TSource, TResult>(IEnumerable<TSource>, Func<TSource, IEnumerable<TResult>>)Projects each element of a sequence to an IEnumerable<T> and flattens the resulting sequences into one sequence.mapMany
SequenceEqual<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)Determines whether two sequences are equal by comparing the elements by using the default equality comparer for their type.
SequenceEqual<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)Determines whether two sequences are equal by comparing their elements by using a specified IEqualityComparer<T>.
Single<TSource>(IEnumerable<TSource>)Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence.
Single<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>)Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists.
SingleOrDefault<TSource>(IEnumerable<TSource>)Returns the only element of a sequence, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence.
SingleOrDefault<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>)Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition.
Skip<TSource>Bypasses a specified number of elements in a sequence and then returns the remaining elements.skip
SkipWhile<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>)Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements.hard to implement
SkipWhile<TSource>(IEnumerable<TSource>, Func<TSource, Int32, Boolean>)Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. The element's index is used in the logic of the predicate function.hard to implement
Sum(IEnumerable<Num>[, ...])Computes the sum of a sequence of Decimal values.sum
Take<TSource>Returns a specified number of contiguous elements from the start of a sequence.take
TakeWhile<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>)Returns elements from a sequence as long as a specified condition is true.hard to implement
TakeWhile<TSource>(IEnumerable<TSource>, Func<TSource, Int32, Boolean>)Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.hard to implement
ThenBy<TSource, TKey>(IOrderedEnumerable<TSource>, Func<TSource, TKey>)Performs a subsequent ordering of the elements in a sequence in ascending order according to a key.
ThenBy<TSource, TKey>(IOrderedEnumerable<TSource>, Func<TSource, TKey>, IComparer<TKey>)Performs a subsequent ordering of the elements in a sequence in ascending order by using a specified comparer.
ThenByDescending<TSource, TKey>(IOrderedEnumerable<TSource>, Func<TSource, TKey>)Performs a subsequent ordering of the elements in a sequence in descending order, according to a key.
ThenByDescending<TSource, TKey>(IOrderedEnumerable<TSource>, Func<TSource, TKey>, IComparer<TKey>)Performs a subsequent ordering of the elements in a sequence in descending order by using a specified comparer.
ToArray<TSource>Creates an array from a IEnumerable<T>.toArray
ToDictionary<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>[,…])Creates a Dictionary<TKey, TValue> from an IEnumerable<T> according to a specified key selector function.groupToMap
ToList<TSource>Creates a List<T> from an IEnumerable<T>.toList
ToLookup<TSource, TKey>(IEnumerable<TSource>, Func<TSource, TKey>[,...])Creates a Lookup<TKey, TElement> from an IEnumerable<T> according to a specified key selector function.
Union<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)Produces the set union of two sequences by using the default equality comparer.union
Union<TSource>(IEnumerable<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)Produces the set union of two sequences by using a specified IEqualityComparer<T>.
Where<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>)Filters a sequence of values based on a predicate.filter
Where<TSource>(IEnumerable<TSource>, Func<TSource, Int32, Boolean>)Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.TODO
Zip<TFirst, TSecond, TResult>Merges two sequences by using the specified predicate function.

Updated