我正在努力使用平均列的正确语法。我所拥有的——来自 RavenDB Studio 编辑器:
地图:
from area in docs.Level5_AdministrativeAreas
select new
{
area.NAME_4,
totalPrice = area.pricePerSquareMetre,
areaCount = 1,
priceAverage = 0
}
减少:
from result in results
group result by new { result.NAME_4 } into g
select new
{
NAME_4 = g.Key.NAME_4,
totalPrice = g.Sum(x => x.totalPrice),
areaCount = g.Sum(x => x.areaCount),
priceAverage = totalPrice / areaCount
}
计数和总价计算正确,但我不知道如何引用totalPrice
和areaCount
.
是否需要额外的选择块?我尝试了“g.totalPrice”和“g.priceAverage”,但它没有被识别。
谢谢您的帮助 !