diamond diamond

diamond diamond

  • NA
  • 133
  • 55.5k

Compute average via linq after group

Oct 24 2014 5:10 AM
Hi
 
I have a such a code blew, I want after grouping, acquire  average of duration variable.
 
var qry = from dr in dt.AsEnumerable()
group dr by new { source = dr["saddr"] } into rowsGroup
select new
{
saddr = rowsGroup.Key,
value = rowsGroup,
daddr = rowsGroup.Count(),
dport = string.Join(",", rowsGroup.Select(av => av["dport"].ToString()).ToList()),
dstip = string.Join(",", rowsGroup.Select(aj => aj["CDaddr"].ToString()).ToList()),
duration = string.Join(",", rowsGroup.Select(av => av["dur"].ToString()).ToList()),
bytes = string.Join(",", rowsGroup.Select(av => av["bytes"].ToString()).ToList()),
pkt = string.Join(",", rowsGroup.Select(av => av["pkts"].ToString()).ToList())
};
 
 
 
 
 
 
 
 

Answers (4)