I don't know if the title is corrent. Please help, I am new in blazor. I want to call a Task function on the blazor component, I want it to be called inside a foreach loop,** not by a click event**.
The thing is, i want a fullname of an employee from the employee table that is linked to person table.The Task GetFullName(int deviceId) return a fullName as a string. I used a Id from device table to get a device from loaned table which have a device table. I get to see the name in the console but not displaying on the table.
Blazor.razor
<table class="table custom-table"><thead><tr><th>Full Name</th></tr></thead><tbody> @foreach (var device in DeviceService.device){ GetFullName(device.Id) ; //error ? @FullName //John Smith }</tbody></table>@code{private string FullName = string.Empty; private async Task<string> EmployeeWithDevice(int deviceId) { //get loan dvice from database by using deviceId' var result = await DeviceLoanService.GetDeviceLoanById(deviceId); var Loan = result.Data; if (result.Success) { FullName = $"{Loan?.Employee?.Person?.FirstName}, {Loan?.Employee?.Person?.LastName}"; } //Console.WriteLine(FullName); return FullName; }}