DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Progressive Query - LINQ

05.07.2012
| 3843 views |
  • submit to reddit
        
Progessive form 
IEnumerable<string> filtered   = names.Where      (n => n.Contains ("a"));
IEnumerable<string> sorted     = filtered.OrderBy (n => n.Length);
IEnumerable<string> finalQuery = sorted.Select    (n => n.ToUpper());
Output

Harry
Mary
Jay

Jay
Mary
Harry

JAY
MARY
HARRY