1
我一直试图找到谷歌和SO强类型List.GroupBy()
一个答案却处处我发现采用匿名类型的结果列表
什么,我想acheive是采取List<SecondaryStandard>
,创造SecondaryStandard
一个分组列表中的每个SecondaryStandard
看起来像这样
public class SecondaryStandard
{
public string Id { get; set; }
public int IdNumeric { get; set; }
public string IdText { get; set; }
public Sample Sample { get; set; }
public string StandardName { get; set; }
public DateTime DateCompleted { get; set; }
public SamplePoint SamplingPoint{ get; set; }
public Instrument Instrument{ get; set; }
public string ContainerId { get; set; }
public double Value { get; set; }
public string ComponentName { get; set; }
public string PointLocation { get; set; }
public string Description { get; set; }
public string Description2 { get; set; }
public string Analysis { get; set; }
public string Units { get; set; }
}
我想要的是一个List(),其中Value属性是每个ComponentName的结果的平均值。
有关如何以强类型方式实现此目的的任何想法,还是需要吸取它并使用匿名对象来实现我在寻找的内容?
'List <>'没有value属性。您将需要创建一个自定义集合类型。 – phoog 2011-12-27 19:44:30
也许你可以澄清结果会是什么?给我们一个带有值的'List'的例子,然后给出你想要的结果,然后我们可以看到如何到达那里。 –
Tejs
2011-12-27 19:48:10
价值是SecondaryStandard的财产 – 2011-12-27 19:51:13