原始SQL看起来像:
SELECT MIN(ID) AS GeoID, MIN(PostalCode), PlaceName
FROM GeoData_ALL
GROUP BY CountryCode, PlaceName
ORDER BY PlaceName
我需要在Dynamic Linq中翻译它,例如:
var searchResult = db.Set(GeoData)
.AsQueryable()
.OrderBy("PlaceName")
.GroupBy("CountryCode", "PlaceName")
.Select("new (MIN(ID) AS GeoID, MIN(PostalCode), PlaceName");
不幸的是' MIN'功能似乎不适用于Dynamic Linq
答案 0 :(得分:0)
以下代码可以提供帮助,请检查(这只是示例代码):
var searchResult = db.Set(GeoData)
.AsQueryable()
.OrderBy("PlaceName")
.GroupBy("CountryCode", "PlaceName")
.Select(g => new { GeoID = g.Min(p => p.ID), PostalCode = g.Min(p => p.PostalCode), PlaceName = g.PlaceName });