var req = (from k in dc.operations.ToList()
group k by k.id_employee into g
select new { id_emp = g.Key , nbr = g.Count(), }
).Take(1).SingleOrDefault();
double mint=0;
for (int i = 0; i < req.nbr; i++)
{
var r = (from l in dc.operations
where l.id_employee == req.id_emp
select l).Take(1).ToList();
var r2 = (from l in dc.operations
where l.id_employee == req.id_emp
&& l.date_operation.Value > r[i].date_operation.Value
select l).Take(1).ToList();
double nbr_minut = (r[i].date_operation.Value - r2[i].date_operation.Value).TotalMinutes;
mint = +nbr_minut;
nbr_minut = 0;
}
TimeSpan span = TimeSpan.FromMinutes(mint);
string nbr_houre = span.ToString(@"hh\:mm");
label1.Text = nbr_houre.ToString();
答案 0 :(得分:0)
为了简化问题,我们假设你有一份人员名单,你想得到最年轻的人和他的年龄。
你可以这样做:
people.OrderBy(p => p.Age).Select(p => new {Dude = p, Age = p.Age}).FirstOrDefault();