This chapter demonstrates about the LINQ Operators. LINQ Standard Query Operators is defined as the set of extension formed a query. Following are the concepts covered in this chapter.
Different Types of Operators
Different Types of Operators
Description
LINQ Operators are have the some range of capabilities like sorting, filtering, aggregation, projection etc and operators are categorised into different types some operators are listed below.
Join Operators
Filtering Operators
Grouping Operators
Sorting Operators
Aggregation Operators
Projection Operators
Set Operations
Quantifier Operators
Equality Operators
Join Operators
Description
Join is a keyword which is used to link two or more collections based on some conditions. Here some Join operators are listed below
Cross Join
Cross Join with Group Join
Group Join
Left Outer Join
Cross Join
Cross join is used perform joining of two collections based on the condition equality.Operator
join
C# Query Expression Syntax
join ... in ... on ... equals ...
VB Query Expression Syntax
From x In ... y In ... Where x.a = y.a
Cross Join with Group Join
Which is both combination of cross join and group join.
Group Join
Group Join is used to perform bundle of elements at a time.
OperatorGroupJoinC# Query Expression Syntaxjoin ... in ... on ... equals ... into ... VB Query Expression Syntax
Group Join ... In ... on ...
Left Outer Join
Left Outer Join is used to join left hand side elements at least once even though the condition is not satisfied.
Filtering Operators
Description
Filtering operators are used to restrict the result set and which have some selected statements to satisfy the condition. Some filtering operators are listed below
Where
ofType
Where
Where is used to get the data based on some condition.
Operator
Where
C# Query Expression Syntax
where
VB Query Expression Syntax
where
ofType
ofType is used to get the data based on some type.
Operator
ofType
C# Query Expression Syntax
Not applicable
VB Query Expression Syntax
Not applicable
Grouping Operators
Description
Grouping operators are used to gather some data into the groups which is based some commonly shared attributes. Some grouping operators are listed below.
groupBy
ToLookup
groupBy
Which gather the sequemce items into group and returns IEnumarable collections of IGrouping type
Operator
GroupBy
C# Query Expression Syntax
group ... by or group ... by ... into ...
VB Query Expression Syntaxgroup ... by ... into ..
ToLookup
Which is used execute the grouping operation in the sequence of key pairs are returned.
Operator
ToLookup
C# Query Expression Syntax
Not applicable
VB Query Expression Syntax
Not applicable
Sorting Operators
Description
Sorting operators are used to arrange the elements in a order based on basis of a attributes. Following are the some sorting operators are listed below.
OrderBy
ThenBy
Reverse
OrderByDescending
ThenByDescending
OrderBy
Which is used sort the values in assending order.
Operator
OrderBy
C# Query Expression SyntaxorderByVB Query Expression SyntaxOrderBy
ThenByWhich is used sort the Secondary values in assending order.Operator
ThenBy
C# Query Expression Syntax
orderby... , ....
VB Query Expression Syntax
Order By ... , ....
Reverse
Which is used to get the reverse order of the elements.
Operator
Reverse
C# Query Expression Syntax
Not applicable
VB Query Expression Syntax
Not applicable
OrderByDescendingWhich is used to sort the values in descending order.Operator
OrderByDescending
C# Query Expression Syntax
orderby ...descending
VB Query Expression Syntax
orderby ...descending
ThenByDescending
Which is used to sort the secondary values in descending order.
Operator
ThenByDescending
C# Query Expression Syntax
orderby... , .... descending
VB Query Expression Syntax
Order By... , .... descending
Aggregation Operators
Description
Aggregation operators are used to crate aggregation LINQ by using desired type of aggregation. Following are the some aggregate operators are shown below.
Min
Max
Count
Sum
Aggergate
Min
Used get the minimum value from the collection.
Operator
Max
C# Query Expression Syntax
Not Applicable
VB Query Expression Syntax
Aggregate ... In ... Into Max()
MaxUsed get the maximum value from the collection.Operator
Min
C# Query Expression Syntax
Not applicable
VB Query Expression SyntaxAggregate ... In ... Into Min()
SumUsed to get the sum of values from the collection.Operator
Sum
C# Query Expression Syntax
Not applicable
VB Query Expression SyntaxAggregate ... In ... Into Sum()
Count
Used to satisfy the predicate function in a collection.
Operator
Count
C# Query Expression Syntax
Not applicable
VB Query Expression SyntaxAggregate ... In ... Into Count()
Aggregate
Used to perform aggregation operation on a collection of values.
Operator
Aggeragate
C# Query Expression Syntax
Not applicable
VB Query Expression Syntax
Not applicable
Projection Operators
Description
Projection is used to transform the object into altogether new form. Following are the some projection operators are listed below.
Select
SelectMany
Select
Which operates the project values based on the transform function.
Operator
Select
C# Query Expression SyntaxSelectVB Query Expression Syntax
Select
SelectMany
Which is used to produce the sequence of values based on transform function.
Operator
SelectMany
C# Query Expression Syntax
Use Multiple form clauses
VB Query Expression Syntax
Use Multiple form clauses
Set Operations
Description
Set operations consist of four operations each operate produce a result based on different criteria. Following are the 4 set operations are listed below.
Except
Union
Distinct
Intersect
Except
Which is used to compare the both the values and return only one value from collection.
Operator
Except
C# Query Expression SyntaxNot applicableVB Query Expression Syntax
Not applicable
Union
Which is used to get the combination different collection list without any dupilcate content.
Operator
Union
C# Query Expression SyntaxNot applicableVB Query Expression SyntaxNot applicable
Distinct
Which is used to filter the duplicate values from the collection.
Operator
Distinct
C# Query Expression Syntax
Not applicable
VB Query Expression SyntaxNot applicable
Intersect
Which is used to produce the identical values fro the collections.
Operator
Intersect
C# Query Expression SyntaxNot applicableVB Query Expression SyntaxNot applicable
Quantifier Operators
Description
Which is used to produce the Boolean values if sequence satisfy the specific condition. Following are the some quantifier operators are listed below.
Any
All
Contain
Any
Which is used search if any element the satisfy the given condition
Operator
Any
C# Query Expression SyntaxNot applicableVB Query Expression Syntax
Aggregate ... In ... Into All (...)
All
Which retuns the True value if all the elements satisfy the given condition.
Operator
All
C# Query Expression Syntax
Not applicable
VB Query Expression Syntax
Aggregate ... In ... Into All (...)
Contain
Which is used to filter the duplicate values from the collection.
Operator
Distinct
C# Query Expression Syntax
Not applicable
VB Query Expression Syntax
Not applicable
Summary
Points
LINQ consist of the several types of operators.
operators are categorised based on their functionality.