views:

61

answers:

1

I want to get the last result returned from this query. How do I do this? Last and LastOrDefault aren't supported by Linq to Sql.

 var docs = (from d in db.Documents                      
                    where d.Version > 1
                    orderby d.DocumentID
                    select new   
                               {                                     
                                   d.DocumentID,
                                   d.DocTypeID,
                                   d.Name,
                                   d.Version
                               });
+4  A: 

Reverse your sort criteria (add descending) and use First (or FirstOrDefault as appropriate).

Jacob Carpenter
perfect. thanks Jacob.
Scott