我在包含以下数据的用户定义类型列表中有一些数据:C#LINQ查询
名称,研究,组,结果,日期。现在我想获得姓名,学习和分组,然后根据结果和日期进行计算。计算是有效的:
log(result).where max(date) minus log(result).where min(date)
有每个名称/学习/组只有两个日期,所以从最大数据(日志)减去的最少日的结果的结果(日志)。这里是我迄今为止没有运气试过的东西:
var result =
from results in sortedData.AsEnumerable()
group results by results.animal
into grp
select new
{
animal = results.animal,
study = results.study,
groupNumber = results.groupNumber,
TGI = System.Math.Log(grp.Select(c => c.volume)
.Where(grp.Max(c=>c.operationDate)))
- System.Math.Log(grp.Select(c => c.volume)
.Where(grp.Min(c => c.operationDate)))
};
有人有指点吗?谢谢。
你能提供一个输入XML的例子吗? – 2011-04-20 16:38:23