Fix integrazione preliminare servizi utils.stats x IOC:

- aggiunta migrations
- correzioni versione ef6 da ef8
- correzioni init varie
This commit is contained in:
Samuele Locatelli
2026-04-07 10:30:04 +02:00
parent 31e786b9fd
commit 45cb6b9f59
32 changed files with 1290 additions and 362 deletions
@@ -1,4 +1,10 @@
using EgwCoreLib.Utils;
using Microsoft.EntityFrameworkCore;
using MP.Data.DbModels.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MP.Data.Repository.Utils
{
@@ -6,7 +12,7 @@ namespace MP.Data.Repository.Utils
{
#region Public Constructors
public StatsDetailRepository(IDbContextFactory<DataLayerContext> ctxFactory) : base(ctxFactory)
public StatsDetailRepository(IDbContextFactory<MoonPro_UtilsContext> ctxFactory) : base(ctxFactory)
{
}
@@ -79,11 +85,20 @@ namespace MP.Data.Repository.Utils
{
DateTime startDate = firstRec.Hour;
DateTime endDate = lastRec.Hour;
// uso direttamente ExecuteDelete
await dbCtx
.DbSetStatsDet
.Where(x => x.Hour >= startDate && x.Hour <= endDate)
.ExecuteDeleteAsync();
// uso direttamente ExecuteDelete quando in EFCore8...
#if false
await dbCtx
.DbSetStatsDet
.Where(x => x.Hour >= startDate && x.Hour <= endDate)
.ExecuteDeleteAsync();
#endif
var items = await dbCtx.DbSetStatsDet
.Where(x => x.Hour >= startDate && x.Hour <= endDate)
.ToListAsync();
dbCtx.DbSetStatsDet.RemoveRange(items);
await dbCtx.SaveChangesAsync();
}
}