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