code_junkie

LINQ group by question

Nov 11th, 2011
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. group by person.cn.Split(separators)[0]
  2.  
  3. group by person.cn.Substring(0,5)
  4.  
  5. string oneSpace = " ";
  6. string fiftySpace = " ";
  7.  
  8. var query =
  9. from person in db.Persons
  10. let lastname = person.cn.Replace(oneSpace, fiftySpace).SubString(0, 50).Trim()
  11. group person by lastname into g
  12. select new { Key = g.Key, Count = g.Count };
Add Comment
Please, Sign In to add comment