Beispiel #1
0
    /// <summary>
    ///     Get construction year distribution by id.
    /// </summary>
    /// <param name="id">Neighborhood identifier.</param>
    public async Task <ConstructionYearDistribution> GetConstructionYearDistributionByIdAsync(string id)
    {
        var sql = @"
                SELECT  -- ConstructionYearDistribution
                        spcy.year_from,
                        spcy.count
                FROM    data.statistics_product_construction_years AS spcy
                WHERE   spcy.neighborhood_id  = @id";

        await using var context = await DbContextFactory.CreateAsync(sql);

        context.AddParameterWithValue("id", id);

        List <ConstructionYearPair> pairs = new();

        await foreach (var reader in context.EnumerableReaderAsync())
        {
            pairs.Add(new()
            {
                Decade     = Years.FromDecade(reader.GetInt(0)),
                TotalCount = reader.GetInt(1)
            });
        }

        return(new()
        {
            Decades = pairs
        });
    }