Grid Template Issues

Hello,
I've been trying to make a name template for my Id column, but I keep getting the errors: "The name 'gameTerritory' does not exist in the current context" && "Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type"

I'm just trying to use my context to get the Id I need to grab the territory name. For some reason, I just can't use the Context like that. Any help would be appreciated. Thanks. Here's my code:

private List<Territory> territories;
private async Task LoadTerritoriesDialog() => await dialogService.OpenAsync("Territories", ds =>
@<RadzenCard Style="padding: 20px; ">
    <div class="row">
        <div class="col-md-12">
            <RadzenGrid @ref="grdGameTerritory" AllowSorting="true" Data="@gameTerritories" TItem="GameTerritory" >
                <Columns>
                    <RadzenGridColumn TItem="GameTerritory" Property="Id" Title="ID" Visible="false" />
                    <RadzenGridColumn TItem="GameTerritory" Property="GameId" Title="Game ID" Visible="false" />
                    <RadzenGridColumn TItem="GameTerritory" Property="TerritoryId" Title="Territory" Width="300px">
                        <Template Context="gameTerritory">
                            @territories.Where(x => x.Id == gameTerritory.TerritoryId).Select(x => x.Name).FirstOrDefault()
                        </Template>
                    </RadzenGridColumn>
                    <RadzenGridColumn Context="gameTerritory" TItem="GameTerritory" Property="OwnerId" Title="Power" Width="200px">
                        <Template Context="gameTerritory">
                            <RadzenDropDown @bind-Value="gameTerritory.OwnerId" AllowClear="true" Data="@powers" TextProperty="Name" ValueProperty="Id" />
                        </Template>
                    </RadzenGridColumn>
                </Columns>
            </RadzenGrid>
        </div>
    </div>
</RadzenCard>);

The code looks correct however since it is not complete I'm not sure what can cause such compilation error. Do you get this for both columns or for one of the columns only?

It is only erroring for the column with Property="TerritoryId". If I get rid of the Template tag, it works. But I want to show the name, not the Id.

Here's the code for the object I'm using as the TItem:

public class GameTerritory
{
    public int GameId { get; set; }
    [Key]
    public int Id { get; set; }
    public string OwnerId { get; set; }
    public int TerritoryId { get; set; }
}

I need to get the name from a list of Territory:

public class Territory
{
    [Key]
    public int Id { get; set; }
    public int IpcValue { get; set; }
    public string Name { get; set; }
    public string OriginalOwner { get; set; }
}

The territories variable is a List and it's fully-populated. My issue is coming from any time I use the gameTerritory Context in my template. Do I have the wrong TItem or wrong column settings? The only way I was able to use the Context was when using a RadzenDropDown like the column with Property="OwnerId", but I don't want to use a dropdown, since I'm just displaying a single string for the name, instead of the int Id that the TerritoryId is. Thank you.

I think the Blazor parser does not recognize the territories variable because it is declared outside of the method. This isn't related to Radzen though. A workaround is to create a separate page for the dialog and inject the context there as you would normally do.