[#79] AppDbContext: Use compiled queries
This commit is contained in:
@@ -413,8 +413,8 @@ namespace Elwig.Helpers {
|
||||
return output.OrderByDescending(l => l.Count());
|
||||
}
|
||||
|
||||
public static List<RawVaribute> GetVaributes(AppDbContext ctx, int year, bool onlyDelivered = true) {
|
||||
var varieties = ctx.WineVarieties.Select(v => new RawVaribute(v.SortId, "", null)).ToList();
|
||||
public static async Task<List<RawVaribute>> GetVaributes(AppDbContext ctx, int year, bool onlyDelivered = true) {
|
||||
var varieties = await ctx.FetchWineVarieties().Select(v => new RawVaribute(v.SortId, "", null)).ToListAsync();
|
||||
var delivered = ctx.DeliveryParts
|
||||
.Where(d => d.Year == year)
|
||||
.Select(d => new RawVaribute(d.SortId, d.AttrId ?? "", d.CultId ?? ""))
|
||||
@@ -423,13 +423,11 @@ namespace Elwig.Helpers {
|
||||
return [.. (onlyDelivered ? delivered : delivered.Union(varieties)).Order()];
|
||||
}
|
||||
|
||||
public static List<Varibute> GetVaributeList(AppDbContext ctx, int year, bool onlyDelivered = true) {
|
||||
var varieties = ctx.WineVarieties.ToDictionary(v => v.SortId, v => v);
|
||||
var attributes = ctx.WineAttributes.ToDictionary(a => a.AttrId, a => a);
|
||||
var cultivations = ctx.WineCultivations.ToDictionary(c => c.CultId, c => c);
|
||||
return GetVaributes(ctx, year, onlyDelivered)
|
||||
.Select(s => new Varibute(s, varieties, attributes, cultivations))
|
||||
.ToList();
|
||||
public static async Task<List<Varibute>> GetVaributeList(AppDbContext ctx, int year, bool onlyDelivered = true) {
|
||||
var varieties = await ctx.FetchWineVarieties().ToDictionaryAsync(v => v.SortId, v => v);
|
||||
var attributes = await ctx.FetchWineAttributes().ToDictionaryAsync(a => a.AttrId, a => a);
|
||||
var cultivations = await ctx.FetchWineCultivations().ToDictionaryAsync(c => c.CultId, c => c);
|
||||
return [.. (await GetVaributes(ctx, year, onlyDelivered)).Select(s => new Varibute(s, varieties, attributes, cultivations))];
|
||||
}
|
||||
|
||||
[LibraryImport("wininet.dll")]
|
||||
|
||||
Reference in New Issue
Block a user