Standard query operators are clauses that enable you to get the data to be used in a .NET application. These operators provide querying capabilities, which includes filtering, projection, aggregation, and sorting. The standard query operators in LINQ are a part of the Application Programming Interface (API) that enables querying of any .NET array or collection. This implies that standard query operations support the implementation of LINQ applications. You can use these standard query operators to perform a data querying operation on a sequence of data.
Standard query operators differ in the time they take to execute a query. The time taken by a query depends on whether the query returns a single value or a sequence of values. The methods that return a sequence of values take more time to return the output in comparison to the methods that return a single value.
|Sorting||change the order elements of a sequence returned by a query|
|Set||Returns a result set in the form of a collection based on the presence or absence of elements within the same set or different sets|
|Filtering||Restricts the result set to contain the elements that satisfy a specific condition|
|Projection||Transforms an object into a different type of new object|
|Partitioning||Divides the input sequence into two sections, without rearranging the elements, and returns one section|
|Grouping||Puts the data into groups such that elements in each groups that elements in each group share a common attribute|
|Join||Joins two data sources with objects that share a common attribute in both the data sources|
|Quantifier||Returns a Boolean value, either True or False, indicating whether all or some of the elements in a given sequence satisfy a specific condition|
|Generation||Creates a new sequence of values|
|Element||Returns a single, specific elements from a collection|
|Conversion||Performs data type conversion|
|Aggregate||Computes a single value from a collection|
|Equality||Checks whether two sequences are equal or not|
|Concatenation||Appends one sequence of elements to another|
|Zip||Combines two collections into one|
Let's now learn about all the query operators in each of the operator types in detail.
Sorting operators in LINQ arrange the elements of a sequence based on one or more attributes. It means that to use the sorting operator, you first need to specify a particular attribute and perform primary sorting on the elements. Then you need to specify the sort criterion and sort the elements within the primary sorted group. Table 1.2 lists all sorting operators in LINQ.
|Clauses||Description||Query Expression Syntax (C#)|
|OrderBy||Sorts a set of elementsin ascending order||orderby|
|OrderByDescending||Sorts a set of elements in descending order||orderby...descending|
|ThenBy||Performs a secondary sort on a set of elements, in ascending order||orderby|
|ThenByDescending||Performs a secondary sort on a set of elements, in descending order||orderby ...descending|
|Reverse||Reverses the order of the elements in a sequence||Not available|