Hooked on LINQ

Hooked on LINQ - Developers' Wiki
for .NET Language Integrated Query

Companion book for this site
LINQ to Objects Using C# 4.0:
Using and Extending LINQ to Objects and Parallel LINQ (PLINQ)
Quick Search

Advanced Search »

Standard Query Operators

Modified: 2012/01/10 10:27 by eti1206 - Categorized as: LINQ to Objects
The Standard Query Operators form the backbone of the query functions as part of LINQ to Objects .

Each operator uses Extension Methods to introduce these query methods to any type that implements the IEnumerable<T> interface.

int[] nums = new int[] {1,2,3,4,5,6,7,8,9};
double avg = nums.Average();

Detailed information and examples about any of the specific operators can be found by clicking on the operator name or by downloading the Standard Query Operator Documentation from Microsoft.

Operator TypeOperatorDescription
AggregationAggregateThe Aggregate operator applies a function over a sequence.
AverageThe Average operator computes the average of a sequence of numeric values.
CountThe Count operator counts the number of elements in a sequence with a return type of int.
LongCountThe LongCount operator counts the number of elements in a sequence with a return type of Long.
MaxThe Max operator finds the maximum of a sequence of numeric values.
MinThe Min operator finds the minimum of a sequence of numeric values.
SumThe Sum operator computes the sum of a sequence of numeric values.
ConcatenationConcatThe Concat operator concatenates two sequences.
ConversionCastThe Cast operator casts the elements of a sequence to a given type.
OfTypeThe OfType operator filters the elements of a sequence based on a type.
ToArrayThe ToArray operator creates an array from a sequence.
ToDictionaryThe ToDictionary operator creates a Dictionary from a sequence.
ToListThe ToList operator creates a List from a sequence.
ToLookupThe ToLookup operator creates a Lookup from a sequence.
ToSequenceThe ToSequence operator returns its argument typed as IEnumerable.
ElementDefaultIfEmptyThe DefaultIfEmpty operator supplies a default element for an empty sequence.
ElementAtThe ElementAt operator returns the element at a given index in a sequence.
ElementAtOrDefaultThe ElementAtOrDefault operator returns the element at a given index in a sequence, or a default value if the index is out of range.
FirstThe First operator returns the first element of a sequence.
FirstOrDefaultThe FirstOrDefault operator returns the first element of a sequence, or a default value if no element is found.
LastThe Last operator returns the last element of a sequence.
LastOrDefaultThe LastOrDefault operator returns the last element of a sequence, or a default value if no element is found.
SingleThe Single operator returns the single element of a sequence.
SingleOrDefaultThe SingleOrDefault operator returns the single element of a sequence, or a default value if no element is found.
EqualityEqualAllThe EqualAll operator checks whether two sequences are equal.
GenerationEmptyThe Empty operator returns an empty sequence of a given type.
RangeThe Range operator generates a sequence of integral numbers.
RepeatThe Repeat operator generates a sequence by repeating a value a given number of times.
GroupingGroupByThe GroupBy operator groups the elements of a sequence.
JoiningGroupJoinThe GroupJoin operator performs a grouped join of two sequences based on matching keys extracted from the elements.
JoinThe Join operator performs an inner join of two sequences based on matching keys extracted from the elements.
OrderingOrderByThe OrderBy operator orders a sequence according to one or more keys in ascending order.
ThenByThe ThenBy operator orders an ordered sequence according to one or more keys in ascending order.
OrderByDescendingThe OrderBy operator orders a sequence according to one or more keys in descending order.
ThenByDescendingThe ThenBy operator orders an ordered sequence according to one or more keys in descending order.
ReverseThe Reverse operator reverses the elements of a sequence.
PartitioningSkipThe Skip operator skips a given number of elements from a sequence and then yields the remainder of the sequence.
SkipWhileThe SkipWhile operator skips elements from a sequence while a test is true and then yields the remainder of the sequence.
TakeThe Take operator yields a given number of elements from a sequence and then skips the remainder of the sequence.
TakeWhileThe TakeWhile operator yields elements from a sequence while a test is true and then skips the remainder of the sequence.
QuantifiersAllThe All operator checks whether all elements of a sequence satisfy a condition.
AnyThe Any operator checks whether any element of a sequence satisfies a condition.
ContainsThe Contains operator checks whether a sequence contains a given element.
RestrictionWhereThe Where operator filters a sequence based on a predicate.
SelectionSelectThe Select operator performs a projection over a sequence.
SelectManyThe SelectMany operator performs a one to many element projection over a sequence.
SetDistinctThe Distinct operator eliminates duplicate elements from a sequence.
ExceptThe Except operator produces the set difference between two sequences.
IntersectThe Intersect operator produces the set intersection of two sequences.
UnionThe Union operator produces the set union of two sequences.


New in January CTP (yet to be categorized by me) -
SequenceEqual


Edit

Resources

LINQ 101 Samples - This Microsoft link shows the source code for the Standard Query Operators. Century 21 Broker Properti Jual Beli Sewa Rumah Indonesia

If you would like to comment on this page, click on the Discuss button located on the top-right of each page. Feel free to edit any mistakes or omissions you find. If you have an objection or find in-appropriate content then contact the administrator. This website is not affiliated with Microsoft®, all content and opinions are those of the specific author and some advice, solutions and article may contain unintentional errors - please use care. Other websites by this author: Focused Objective, Geek Speak Decoded.