Dynamic Linq for SQL MIN() function -
original sql looks like:
select min(id) geoid, min(postalcode), placename geodata_all group countrycode, placename order placename
i need translate in dynamic linq, like:
var searchresult = db.set(geodata) .asqueryable() .orderby("placename") .groupby("countrycode", "placename") .select("new (min(id) geoid, min(postalcode), placename");
unfortunately 'min' function doesn't seem applicable dynamic linq
following code can help, please check (this 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 });
Comments
Post a Comment