Q:

Aggregate 2 collections to parent / child

I'm not sure if the way I found to solve this problem is a good one or not. 
Example scenario:
class FolderItem
{
    public int Id { get; set; }
    public string Name { get; set; }
    public FileItem[] Files { get; set; }
}

class FileItem
{
    public int Id { get; set; }
    public int FolderId { get; set; }
    public string Name { get; set; }
    public byte[] Content { get; set; }
}

Starting from 2 collections:
FolderItem[] folders = 
    new FolderItem[]
    {
        new FolderItem
        {
            Id = 1,
            Name = "Folder1"
        },
        new FolderItem
        {
            Id = 2,
            Name = "Folder2"
        }
    };

FileItem[] files = 
    new FileItem[]
    {
        new FileItem
        {
            Id = 100,
            FolderId = 1,
            Name = "file1.txt",
            Content = new byte[] { 1, 2, 3 }
        },
        new FileItem
        {
            Id = 200,
            FolderId = 1,
            Name = "file2.txt",
            Content = new byte[] { 1, 2, 3 }
        },
        new FileItem
        {
            Id = 300,
            FolderId = 2,
            Name = "file3.txt",
            Content = new byte[] { 1, 2, 3 }
        },
        new FileItem
        {
            Id = 400,
            FolderId = 2,
            Name = "file4.txt",
            Content = new byte[] { 1, 2, 3 }
        }
    };

In order to put 'FileItem' into the property 'Files' of 'Folder', I do:
 files
    .Join
    (
        folders,
        x => x.FolderId,
        x => x.Id,
        (x,y) => new { File = x, Folder = y }
    )
    .GroupBy(x => x.Folder. Id)
    .Select
    (x => 
        { 
            var folder = x.First().Folder;
            folder. Files = x.Select(z => z.File).ToArray();
            return folder;
        }
    )

I can use .First() in the GroupBy lambda because I'm grouping by its id
I get:

Is there some extension method that can do quicker or better than this?  Are there any best practices? 

A:

Just create a new list, using Where to get the files for each folder. 
var foldersWithFiles = folders
    .Select
    (
        folder =>
        new FolderItem
        {
            Id = folder. Id,
            Name = folder. Name,
            Files = files. Where
            (
                file => file. FolderId = folder. Id
            ).ToArray()
        )
    );

You can always replace the old list afterward, like this:
folders = foldersWithFiles. ToArray();

