I've built a Blazor application, and I wrote some logic in a for-each loop to display some data. The logic is meant to go something like this: for every job type, display the jobs for that particular type that are in the database.
@foreach (var types in Types)
{
@GetByType(@types.ID)
@if (jobs!= null)
{
<RadzenRow>
<RadzenColumn>
<RadzenText TextStyle="TextStyle.H6">@types.Description</RadzenText>
</RadzenColumn>
</RadzenRow>
<hr>
<br />
<MatTable Items="@jobs" class="mat-elevation-z5">
<MatTableHeader>
<th>Opening</th>
<th>Location</th>
</MatTableHeader>
<MatTableRow>
<td>@context.Name</td>
<td>@context.Location</td>
</MatTableRow>
</MatTable>
}
As you can see, I've written a function that gets called in order to call a function from my jobs repository and populate a variable based on the type of job. I'm trying to populate my jobs variable and bind that to my grid. I set it to null before each run of the database in order to clear out the previous records.
private IEnumerable<Locations> Locations { get; set; } = new List<Locations>();
private IEnumerable<JobTypes> Types { get; set; } = new List<JobTypes>();
private IEnumerable<Jobs>? jobs { get; set; } = new List<Jobs>();
private async Task GetByType(int ID)
{
jobs = null;
jobs = await jobsRepository.GetByType(ID);
}
The job types themselves are populated in OnInitializedAsync. I tested the types first on their own in the for loop without the grid, and they all displayed correctly. But when the page loads with everything else added, it is displaying the following (no server error or anything; no errors at all in the console, just the below code where the grid would normally be):
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[System.Threading.Tasks.VoidTaskResult,Test.Components.Pages.Home+<GetByType>d__43]System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[System.Threading.Tasks.VoidTaskResult,Test.Components.Pages.Home+<GetByType>d__43]System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[System.Threading.Tasks.VoidTaskResult,Test.Components.Pages.Home+<GetByType>d__43]System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[System.Threading.Tasks.VoidTaskResult,Test.Components.Pages.Home+<GetByType>d__43]System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[System.Threading.Tasks.VoidTaskResult,Test.Components.Pages.Home+<GetByType>d__43]System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[System.Threading.Tasks.VoidTaskResult,Test.Components.Pages.Home+<GetByType>d__43]System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[System.Threading.Tasks.VoidTaskResult,Test.Components.Pages.Home+<GetByType>d__43]System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[System.Threading.Tasks.VoidTaskResult,Test.Components.Pages.Home+<GetByType>d__43]
The first thing that I thought to check was the query that pulls the data in the repository. But when I debugged this, the data itself appears to be pulling correctly. Any help would be appreciated as to why I'm getting this error. Thanks!