Obtaing DataSource
From clause is used to include
Selection
Select clause is used to specify type of result sequence returned after execution of query
Syntax:
select <rangevariable>;
select new { rangevariable1, rangevariable2,..}
Filtering
Ordering
Executing
Grouping
From clause is used to include
- Data source
- Range Variable : which store each element of data source.
- Syntax: from <rangevariable> in <datasource objcet>
Selection
Select clause is used to specify type of result sequence returned after execution of query
Syntax:
select <rangevariable>;
select new { rangevariable1, rangevariable2,..}
Filtering
- Only those element for which the expression is true is returned by the query.
- Any C# logical and relation operators can be used to specify expression.
- Syntax: where <condition1 on range variable> [<logical operator>] <condition2 on rangevariable>
Ordering
- orderby clause cause the data to be returned in sorted order (ascending or descending)
- Default order is ascending.
- Syntax: orderby rangevariable [[ascending | descending], ..]
Executing
- foreach loop is used to iterate through each element of range variable returned by LINQ query.
- Syntax: foreach (datatype loopvariable in linqqryvariable) { …. }
Grouping
- Groupby clause is used to group your results based on a key specified by the user
- Grouping refers to the operation of putting data into groups so that the elements in each group share a common attribute.
- Syntax: group <range variable> by <grouping criteria>
Let clause
- Let clause creates a new range variable and store the result of sub expression.
- Once initialized range variable cannot store another value
- Syntax: let <new range variable> = [LINQ expression | other expression]
Set Operations
Based on the presence or absence of equivalent elements within the same or separate collections. The operations are
- Distinct: Remove duplicate values from the collections
- Except: Elements in first input sequence that are not in second input sequence.
- Intersect: Elements that are common to both input sequence.
- Union: Unique elements from both sequence.
No comments:
Post a Comment