Standard query operator
1. In LINQ, the query variable itself does not perform any operations and does not return any data.
It only stores the information necessary to generate results when a query is executed at a later time.
2. The "standard query operator" is a method that forms the Language Integrated Query (LINQ) mode.
There are two groups of standard query operators for LINQ, one running on an object of the IEnumerable (T) type and the other running on an object of the IQueryable (T) type.
* If you must reference the results of group operations, you can use the into keyword to create an identifier that can be further queried.
1 class StandSearchToLinq: Interface
2 {
3 # region Interface Members
4
5 public void invoke ()
6 {
7 string sentence = "the quick brown fox jumps over the lazy dog ";
8 string [] words = sentence. Split ('');
9 // standard query
10 var query = from word in words
11 group word. ToUpper () by word. Length into gr
12 orderby gr. Key
13 select new {Length = gr. Key, Words = gr };
14
15 // Lambda
16 var query2 = words. groupBy (w => w. length, w => w. toUpper ()). select (g => new {Length = g. key, Words = g }). orderBy (o => o. length );
17
18 foreach (var obj in query2)
19 {
20 Console. WriteLine ("Words of Length {0}:", obj. Length );
21 foreach (string word in obj. Words)
22 Console. WriteLine (word );
23}
24}
25
26 # endregion
27}
LINQ Coding directory
- Linq Coding -- Part One
- Linq Coding -- Part Two [standard query operator]
- Linq Coding -- Part Three [Let clause]
- Linq Coding -- Part Four [Concat application]
- Linq Coding -- Part Five (Join Internal Join query)
- Linq Coding -- Part Six (Join Group Join)
- Linq Coding -- Part Seven (Join: left Outer Join, DefaultIfEmpty, GroupJoin)