的最小值我有以下的列LINQ查詢發現一列
inspection_dt,
contact_dt,
description,
product_mod,
product_desc,
contact_nm,
history_id,
inspect_id,
history_type,
incident_product_id,
contact_history_id
我會使用LINQ從該表中查詢行的泛型列表的表。我想要的是history_id的最小值(MIN) - 並且模仿這個SQL查詢。
SELECT DISTINCT
inspection_dt,
contact_dt,
description,
product_mod,
product_desc,
contact_nm,
MIN(history_id) AS history_id,
inspect_id,
history_type,
incident_product_id,
contact_history_id
FROM
myTable
GROUP BY
inspection_dt,
contact_dt,
description,
product_mod,
product_desc,
contact_nm,
inspect_id,
history_type,
incident_product_id,
contact_history_id
我已經試過像片段
var searchData = items
.GroupBy(i => new { i.history_id })
.Select(g => new { history = g.Min() })
.Distinct();
但仍得到全亂了
我開始使用像MIN,MAX等功能卡,並在LINQ分組並希望任何幫助我可以得到。
謝謝,