I have dependency ICollectionService
:
public class CollectionService : ICollectionService
{
public async Task<bool> IsObtained(int gameId)
{
using (DatabaseContext context = _contextFactory.CreateDbContext())
{
List<CollectionGame> collectionGame = await context.Set<CollectionGame>().Where<CollectionGame>(cg => cg.GameId.Equals(gameId)).ToListAsync();
return collectionGame.FirstOrDefault<CollectionGame>().Obtained;
}
}
}
The object [Obtained]
is a bool
in the backend.
I have injected ICollectionService
in page Games.razor
:
@inject ICollectionService ICollectionService
// ...
<tbody>
@foreach (var game in games)
{
<tr>
<td>@game.Upc</td>
<td>@game.Title</td>
<td class="center"><input type="checkbox" @bind="ICollectionService.IsObtained(game.Id)"></td>
<td>@game.Paid</td>
</tr>
}
</tbody>
// ...
game.Id
is an int
.
I am receiving the following error caused by line <td class="center"><input type="checkbox" @bind="ICollectionService.IsObtained(game.Id)"></td>
Severity Code Description Project File Line Suppression State
Error CS0131 The left-hand side of an assignment must be a variable, property or indexer ProjectName ...\SolutionName\ProjectName\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_Games_razor.g.cs 215 Active
I have checked my code and I am unsure why this error is being thrown. May you please advise?
TIA.