Grouping a generic list via LINQ in VB.NET
- by CD Smith
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