views:

23

answers:

1

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;
A: 

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;
tzaman
fantastic. Thanks!
Grant
You're welcome! :)
tzaman