[#79] AppDbContext: Use compiled queries

This commit is contained in:
2026-04-04 15:28:30 +02:00
parent 9c39a2f820
commit d051a2bfcf
42 changed files with 393 additions and 379 deletions

View File

@@ -74,7 +74,7 @@ namespace Elwig.Windows {
}
var areaComCount = await areaComQuery.CountAsync();
var season = await ctx.Seasons.FindAsync(await ctx.Seasons.MaxAsync(s => s.Year));
var season = await ctx.FetchSeasons().FirstOrDefaultAsync();
var stat = await AreaComService.GenerateToolTipData(areaComQuery, season?.MaxKgPerHa ?? 10_000);
return (filter, contracts, areaComs, areaComCount, stat);
@@ -163,7 +163,7 @@ namespace Elwig.Windows {
protected override async Task OnRenewContext(AppDbContext ctx) {
await base.OnRenewContext(ctx);
if (await ctx.Members.FindAsync(ViewModel.FilterMember.MgNr) is not Member m) {
if (await ctx.FetchMembers(ViewModel.FilterMember.MgNr).SingleOrDefaultAsync() is not Member m) {
Close();
return;
}
@@ -180,12 +180,8 @@ namespace Elwig.Windows {
.Include(c => c.WineAttr)
.OrderBy(v => v.VtrgId)
.ToListAsync());
ControlUtils.RenewItemsSource(MemberInput, await ctx.Members
.OrderBy(m => m.Name).ThenBy(m => m.GivenName).ThenBy(m => m.MgNr)
.ToListAsync());
var cultList = await ctx.WineCultivations
.OrderBy(c => c.Name)
.Cast<object>().ToListAsync();
ControlUtils.RenewItemsSource(MemberInput, await ctx.FetchMembers(includeNotActive: true).ToListAsync());
var cultList = await ctx.FetchWineCultivations().Cast<object>().ToListAsync();
cultList.Insert(0, new NullItem());
ControlUtils.RenewItemsSource(WineCultivationInput, cultList, null, ControlUtils.RenewSourceDefault.First);
await RefreshList();