student[] StAry ={ NewStudent ("Zhang San","male", -), NewStudent ("Xiao Ming","male", -), NewStudent ("Lili","female", -), NewStudent ("Xiao Ju","female", -), NewStudent ("Zhang Si","male", -), NewStudent ("Zhang Eight","male", -), }; varQuery1 = fromVallinchStArySelectVall; foreach(Student StinchQuery1) System.Console.WriteLine (ST); varQuery2 = fromVal2inchStArySelectVal2. Age; foreach(varAgeinchQuery2) {System.Console.WriteLine ("{0}", age); } varQuery3 = fromVal2inchStArySelectVal2. Name.length; foreach(varNameinchquery3) {System.Console.WriteLine (name); }View Code
Where to use:
int[] ary = {1,3,9, A, the, A, -, -, the, $, + }; varQuery1 = fromVal1incharywhereVal1 > the SelectVal1; foreach(varValinchQuery1) System.Console.WriteLine (val);
Usage by:
Student [] stary= { NewStudent ("Wangxiao","male", -), NewStudent ("Chang Buri Rate Army","male", A), NewStudent ("Xu Xian Yu Yu","male", A), NewStudent ("a flower","female", -), }; varQuery1 = fromVal1inchStary byVal1. AgeSelectVal1; foreach(varStinchQuery1) {System.Console.WriteLine ("{0}--{1}--{2}", St. Name, St. Xingbie, St. Age); }
The default is ascending, ascending, and can be set to descending desending.
Multiple keywords can be specified
If more than one is present in the same query, only the last one is valid. The effect differs from where's fetch-set.
GROUP BY group:
varQuery1 = fromStinchStary Group St by St. Xingbie; foreach(varGrpinchQuery1) {System.Console.WriteLine (GRP. Key); foreach(varStuinchGRP) {System.Console.WriteLine (STU); } } varQuery2 = fromStinchStary Group St by St. Age to Stgrp_ageSelectStgrp_age; foreach(varAgeinchQuery2) {System.Console.WriteLine (age. Key+":"); foreach(varStuinchAge ) {System.Console.WriteLine (STU); } }
LINQ----1