LINQ coding-(2) [standard query operator]

Source: Internet
Author: User
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 integration query (LINQ) mode.
There are a total of two groups of standard query operators in the LINQ, one group in the type of ienumerable (T) And the other is in the iqueryable type. (T) .
* 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 }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.