Hi can someone help开发者_高级运维 me convert this tsql statement into c# linq2sql?
select [series] from table group by [series] order by max([date]) desc
This is what i have so far - the list is not in correct order..
var x = from c in db.Table
orderby c.Date descending
group c by c.Series into d
select d.Key;
Your LINQ orderby
clause isn't doing the same thing as your SQL one. Here, this should fix it:
var query = from c in db.Table
group c by c.Series into d
orderby d.Max(item => item.Date) descending
select d.Key;
精彩评论