First, the LINQ advanced Search
1. Fuzzy check (string contains)
View Code
2. Check the beginning (StartsWith, start with XX)
Public list<user> Select (string name) { return con. User.where (r = R.username.startswith (name)). ToList (); }
3. Check the end
Public list<user> Select (string name) { return con. User.where (r = R.username.endswith (name)). ToList (); }
4. The array length (number) found
CList. Count ()
5. Max value: Max (r = r.price);
Public decimal? Selectmax () { return Con.car.Max (r = r.price); }
6. Minimum value: min (r = r.price);
Public decimal? Selectmin () { return con.car.Min (r = r.price); }
7. Average: Average (r = r.price);
Public decimal? Selectavg () { return con.car.Average (r = r.price); }
8. Sum: sum (r = r.price);
Public decimal? Selectsum () {return Con.car.Sum (r = r.price);}
9. Sort:
1. Order orders by ascending value.
2. OrderByDescending the values in descending order
3. ThenBy performs a secondary sort in ascending order.
4. ThenByDescending performs a secondary sort in descending order.
(1) Ascending: ORDER by (r = r.price)
Public list<car> () { return con.car.OrderBy (r = r.price). ToList (); }
(2) Descending: orderbydescending (r = r.price)
Public list<car> () { return con.car.OrderByDescending (r = r.oil). ToList (); }
Second, pagination and combination query
aspxAspx.cs
WEBFORM--LINQ Page Combination Query