1

我正在尝试按优先级对我的票证进行分组,并计算出在这些分组的优先级中解决每个票证的平均时间。我不确定如何获得投影的平均值。如何在我的投影中插入平均值公式,这本质上是由 minElapse 划分的票数。它说 minElapse 不在当前上下文中。因为我正在分组并使用 Let this,所以我对如何使用变量 minElapse 感到困惑。谢谢

var results = from r in Tickets
where r.Team.Equals("ABC") && DateCreated >1330001100 && r.DateCreated<1350000000  //unix time
let minElapse = r.FinishDate - r.DateCreated
group r by r.priority into u
select new {  
    Priority = u.Key,
TicketCount = u.Count(),
AverageMin = u.Average( c => minElapse)
};
4

1 回答 1

1

你可以让它不使用let

var results = from r in Tickets
where r.Team.Equals("ABC") && r.DateCreated>1330001100 && r.DateCreated<1350000000
group r by r.priority into u
select new 
{  
    Priority = u.Key,
    TicketCount = u.Count(),
    AverageMin = u.Average(x => x.FinishDate - x.DateCreated)
};
于 2013-07-22T21:37:19.503 回答