Я пытаюсь вывести результаты запроса LINQ в группах. Все элементы списка являются строками. Строка, к которой присоединяются два списка, - это AssociatedCase. Два списка:
InternalIssue
- {Id, Key, ReadMe, AssociatedCase}
{"44", "INT-44", "this is the read me for 44", "1234"}
{"54", "INT-54", "this is the read me for 54", "1234"}
{"54", "INT-54", "this is the read me for 54", "5678"}
{"55", "INT-55", null, "9999"}
ExternalCase
- {CaseName, Account, Contact, AssociatedCase}
{"EXC-222", "1234", "Nike", "Nancy"}
{"EXC-111", "5678", "Reebok", "Amber"}
{"EXC-000", "9999", "Puma", "Susan"}
Я пробовал предложения из похожих постов, но не могу заставить его работать - обычно некоторые элементы списка становятся недоступными, когда я начинаю пытаться группировать и объединять списки вместе.
var query = issueList.Join(caseList,
i => i.AssociatedCase,
c => c.AssociatedCase,
(i, c) => new
{
i.Key,
i.ReadMe,
c.CaseName,
c.Account,
c.Contact
});
foreach (var issue in query)
{
Console.WriteLine($"{issue.Key} - {issue.ReadMe}\n" +
$"\t{issue.CaseName} - {issue.Account}, {issue.Contact}");
}
Вот что я хочу:
(INT-44) - this is the read me for 44
(EXC-222) - Nike, Nancy
(INT-54) - this is the read me for 54
(EXC-111) - Reebok, Amber
(EXC-222) - Nike, Nancy
(INT-55) -
(EXC-000) - Puma, Susan
... но вот что я получаю:
(INT-44) - this is the read me for 44
(EXC-222) - Nike, Nancy
(INT-54) - this is the read me for 54
(EXC-222) - Nike, Nancy
(INT-54) - this is the read me for 54
(EXC-111) - Reebok, Amber
(INT-55) -
(EXC-000) - Puma, Susan