的最小值我有以下的列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分组并希望任何帮助我可以得到。
谢谢,