Original SQL looks like:
SELECT MIN(ID) AS GeoID, MIN(PostalCode), PlaceName
FROM GeoData_ALL
GROUP BY CountryCode, PlaceName
ORDER BY PlaceName
I need to translate it in Dynamic Linq, something like:
var searchResult = db.Set(GeoData)
.AsQueryable()
.OrderBy("PlaceName")
.GroupBy("CountryCode", "PlaceName")
.Select("new (MIN(ID) AS GeoID, MIN(PostalCode), PlaceName");
Unfortunately 'MIN' function doesn't seem applicable to Dynamic Linq
Following code can help, please check (this is a sample code only):
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 });