Web-Development-with-Blazor.../Chapter03/MyBlog/BlazorServer/Pages/FetchDataWithInherits.razor.cs
2023-02-17 15:28:17 +01:00

25 lines
716 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using BlazorServer.Data;
namespace BlazorServer.Pages
{
//This class is named something completelly different than the razor file (even if the file is named the same)
public class FetchDataWithInheritsModel:ComponentBase
{
[Inject]
public WeatherForecastService ForecastService { get; set; }
protected WeatherForecast[] forecasts;
protected override async Task OnInitializedAsync()
{
forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
}
}
}