AppDbContext: Add v_area_commitment_bin
This commit is contained in:
@ -215,17 +215,7 @@ namespace Elwig.Helpers {
|
||||
cnx ??= await ConnectAsync();
|
||||
var bins = new Dictionary<int, Dictionary<string, (int, int)>>();
|
||||
using (var cmd = cnx.CreateCommand()) {
|
||||
cmd.CommandText = $"""
|
||||
SELECT mgnr, t.vtrgid,
|
||||
ROUND(SUM(COALESCE(area * min_kg_per_ha, 0)) / 10000.0) AS min_kg,
|
||||
ROUND(SUM(COALESCE(area * max_kg_per_ha, 0)) / 10000.0) AS max_kg
|
||||
FROM area_commitment c
|
||||
JOIN area_commitment_type t ON t.vtrgid = c.vtrgid
|
||||
WHERE (year_from IS NULL OR year_from <= {year}) AND
|
||||
(year_to IS NULL OR year_to >= {year})
|
||||
GROUP BY mgnr, t.vtrgid
|
||||
ORDER BY LENGTH(t.vtrgid) DESC, t.vtrgid
|
||||
""";
|
||||
cmd.CommandText = $"SELECT mgnr, bin, min_kg, max_kg FROM v_area_commitment_bin WHERE year = {year}";
|
||||
using var reader = await cmd.ExecuteReaderAsync();
|
||||
while (await reader.ReadAsync()) {
|
||||
var mgnr = reader.GetInt32(0);
|
||||
|
Reference in New Issue
Block a user