without using GroupJoin:
var playersDictionary = players.ToDictionary(player => player.Id,
element => new PlayerDto { Rounds = new List<RoundDto>() });
foreach (var round in rounds)
{
PlayerDto playerDto;
playersDictionary.TryGetValue(round.PlayerId, out playerDto);
if (playerDto != null)
{
playerDto.Rounds.Add(new RoundDto { });
}
}
var playerDtoItems = playersDictionary.Values;
using GroupJoin:
var playerDtoItems =
from player in players
join round in rounds
on player.Id equals round.PlayerId
into playerRounds
select new PlayerDto { Rounds = playerRounds.Select(playerRound => new RoundDto {}) };
Which of these two pieces is more efficient?