문제

I'm trying to group my tickets by priority and figure out the average of time to resolve each ticket within those grouped priorities. I'm not sure how to go about getting the average in projection. How do I go about inserting the formula for the average in my projection, which is essentially number tickets devide by minElapse. It says minElapse is not in the current context. Being I'm grouping and using Let this is where I get confused on how to use the variable minElapse. Thanks

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)
};
도움이 되었습니까?

해결책

You could just make it not use a 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)
};
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top