Grouping a generic list via LINQ in VB.NET
Posted
by
CD Smith
on Stack Overflow
See other posts from Stack Overflow
or by CD Smith
Published on 2011-06-26T23:36:31Z
Indexed on
2011/06/27
0:22 UTC
Read the original article
Hit count: 296
I need to take a collection and group it via Linq but all the examples I've seen fail in some manner or other with some syntax difference that I can't quite lick.
My collection:
Dim a As New List(Of ProcessAlert)
a.Add(New ProcessAlert("0000112367", "[email protected]", "Alert", 2))
a.Add(New ProcessAlert("0000112367", "[email protected]", "Document", 2))
a.Add(New ProcessAlert("0000112367", "[email protected]", "Note", 2))
a.Add(New ProcessAlert("0000112367", "[email protected]", "Alert", 1))
a.Add(New ProcessAlert("0000112367", "[email protected]", "Document", 1))
a.Add(New ProcessAlert("0000112367", "[email protected]", "Note", 1))
Return a
I need to turn this collection into a simple way to give this final outcome:
"[email protected]", "Alert, Document, Note"
"[email protected]", "Alert, Document, Note"
Here's the definition of the ProcessAlert
class:
Public Class ProcessAlert
Public LoanNumber As String
Public EmailAddress As String
Public AlertType As String
Public AlertMethodID As Byte
End Class
Thanks in advance,
CD
© Stack Overflow or respective owner