Когда некоторые данные загружаются и отображаются, и я перезагружаю страницу, я получаю сообщение об ошибке.
System.InvalidOperationException: Invalid Operation. Соединение закрыто
Вот код службы, которая завершается с ошибкой:
Код: Выделить всё
namespace PlanificationFineARS.Services
{
public class OFService : IOFService
{
private readonly PlanificationFineARSContext _context;
public OFService(PlanificationFineARSContext context) {
_context = context;
}
public Task GetAllOFsInPochette(DateOnly startDate, DateOnly endDate)
{
return _context.OF
.Where(of => of.pochette != null &&
of.datePrevision >= startDate &&
of.datePrevision of.datePrevision)
.Include(of => of.pochette)
.ToListAsync();
}
}
}
Код: Выделить всё
protected TableMachine OFsTab1;
protected TableMachine OFsTab2;
protected TableMachine OFsTab3;
//...
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
LoadInitialData();
}
protected async void LoadInitialData()
{
DateTime baseDate = DateTime.Today;
startDateTime = baseDate.AddDays(-(int)baseDate.DayOfWeek);
endDateTime = startDateTime.AddDays(7).AddSeconds(-1);
startDate = DateOnly.FromDateTime(startDateTime);
endDate = DateOnly.FromDateTime(endDateTime);
await makeFullOFsList(startDate, endDate);
this.StateHasChanged();
OFsTab1.RefreshMe();
OFsTab2.RefreshMe();
OFsTab3.RefreshMe();
}
protected async Task makeFullOFsList(DateOnly startDate, DateOnly endDate)
{
isLoading = true;
List AllOFs = new List();
try
{
AllOFs = await OFService.GetAllOFsInPochette(startDate, endDate);
}
catch (System.InvalidOperationException ioe)
{
Console.WriteLine(ioe);
}
//...
}
Код: Выделить всё
fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
Failed executing DbCommand (21ms) [Parameters=[@__startDate_0='?' (DbType = Date), @__endDate_1='?' (DbType = Date)], CommandType='Text', CommandTimeout='30']
SELECT [o].[Id], [o].[clientName], [o].[comment], [o].[dateExpedition], [o].[dateFabrication], [o].[datePrevision], [o].[designation], [o].[diameter], [o].[machine], [o].[mandrin], [o].[nCommande], [o].[nOF], [o].[numero], [o].[pochetteId], [o].[productionTime], [o].[quantity], [o].[timeTH], [o].[totalWidth], [o].[width], [p].[Id], [p].[machine], [p].[nPochetteText], [p].[timeTotal], [p].[totalWidth]
FROM [OF] AS [o]
LEFT JOIN [Pochette] AS [p] ON [o].[pochetteId] = [p].[Id]
WHERE [p].[Id] IS NOT NULL AND [o].[datePrevision] >= @__startDate_0 AND [o].[datePrevision]
Подробнее здесь: [url]https://stackoverflow.com/questions/79786403/system-invalidoperationexception-invalid-operation-the-connection-is-closed[/url]
Мобильная версия