Created
March 7, 2014 18:30
-
-
Save dshook/9417081 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Main() | |
| { | |
| var bob_banana = new person(){name = "bob banana", age = 5,friends = new List<string>(){"bobo", "bilbo", "brandon"} }; | |
| var tim_truffle = new person(){name = "tim truffle", age = 300, friends = new List<string>(){"tom", "trudy", "trouble"} }; | |
| var clyde_carrot = new person(){name = "clyde carrot", age = 30, friends = new List<string>(){"clog", "clod", "clop"} }; | |
| var people = new List<person>(){bob_banana, tim_truffle, clyde_carrot}; | |
| var info = people | |
| .Where (p => p.age > 20) | |
| .SelectMany(p => p.friends) | |
| .Distinct() | |
| .GroupBy (f => f.Length) | |
| .Select (g => | |
| string.Format("There are {0} names with {1} letters" | |
| , g.Count() | |
| , g.Key | |
| ) | |
| ); | |
| info.Dump("Info"); | |
| var quarryInfo = | |
| from p in people | |
| where p.age > 20 | |
| from f in p.friends.Distinct() | |
| group f by f.Length into g | |
| select string.Format("There are {0} names with {1} letters" , g.Count(), g.Key); | |
| quarryInfo.Dump("Quarry info"); | |
| } | |
| class person{ | |
| public string name{get;set;} | |
| public int age{get;set;} | |
| public List<string> friends{get;set;} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment