score:2

Accepted answer

this should be a straightforward translation of the sql:

from s in db.tblsearches
where
    s.seaprice >= 2000 &&
    s.seaprice <= 7000
group s by new {s.seamake, s.seamodel} into g
orderby g.key
select new
{
    make =  g.key.seamake,
    model = g.key.seamodel,
    count = g.count(),
    from =  g.min(x => x.seaprice),
    capid = g.min(x => x.seacapid)
}

score:1

instead of your original collection of ienumerable<typeofs> when you grouped into g you converted that collection into an ienumerable> so the collection in current scope is g. so the following would be valid

from s in db.tblsearches
where s.seaprice >= 2000
   && s.seaprice <= 7000
orderby s.seamake
group s by s.seamake into g // the collection is now ienumerable<igrouping<typeofseamake, typeofs>>
select new {
    make = g.key, // this was populated by s.seamake
    model = g.first().seamodel, // get the first item in the collection
    count = g.max(x => x.seamake), // get the max value from the collection
    pricefrom = g.min(x => x.seaprice), // get the min price from the collection
};

there will now be one item returned for each grouping


Related Query

More Query from same tag