私のクラスの定義
Public Class ProcessAlert
Public LoanNumber As String
Public EmailAddress As String
Public AlertType As String
Public AlertMethodID As Byte
End Class
DB から返されるデータを表す一般的なリスト
Dim a As New List(Of ProcessAlert)
a.Add(New ProcessAlert("0000112367", "5551110000@txt.att.net", "Alert", 2))
a.Add(New ProcessAlert("0000112367", "5551110000@txt.att.net", "Document", 2))
a.Add(New ProcessAlert("0000112367", "5551110000@txt.att.net", "Note", 2))
a.Add(New ProcessAlert("0000112367", "jdoe@home.com", "Alert", 1))
a.Add(New ProcessAlert("0000112367", "jdoe@home.com", "Document", 1))
a.Add(New ProcessAlert("0000112367", "jdoe@home.com", "Note", 1))
Return a
LoanNumber と EmailAddress でグループ化するこの LINQ ステートメントを管理しましたが、AlertType を 3 つの値すべての連結フィールドとして表示することはできません
Dim res = Alerts.GroupBy(Function(g) New With {Key .A = g.LoanNumber, Key .B = g.EmailAddress})
このコードにより、EmailAddress と必要な値でグループ化されます: "jdoe@home.com"、"Alert、Document、Note"
Dim res = Alerts.GroupBy(Function(i) i.EmailAddress).Select(Function(g) New KeyValuePair(Of String, String)(g.Key, String.Join(",", g.Select(Function(x) x.AlertType).ToArray())))
しかし、ステートメントから次のようなリターンが得られるようには見えません。
"0000112367","jdoe@home.com", "Alert, Document, Note"
"0000112367","5551112222@txt.att.net", "Alert, Document, Note"
2 つのフィールドをグループ化してから、AlertType の値を 1 つのフィールドに連結するにはどうすればよいですか?
前もって感謝します