Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • Combined with Linq.Enumerable.Aggregate() this even allows for grouping by a dynamic number of properties: propertyValues.Aggregate((current, next) => current + " " + next). Commented Aug 1, 2017 at 7:51
  • 4
    This is a better answer than anyone is giving credit for. It may be problematic if there could be instances of combinations where column1 added to column2 would equal the same thing for situations where column1 differs ("ab" "cde" would match "abc" "de"). That said, this is a great solution if you can't use a dynamic type because you are pre-constructing lambdas after the group by in separate expressions. Commented Apr 19, 2018 at 19:14
  • 3
    "ab" "cde" should actually not match "abc" "de", hence the blank in between. Commented May 8, 2018 at 6:29
  • 2
    what about "abc de" "" and "abc" "de "? Commented Mar 15, 2019 at 19:24
  • @AlbertK yes, that is an instance that won't work, because both cases lead to the group key "abc de "... Commented Nov 9, 2022 at 15:31