Get the record (row) in a table with the most recent (greatest date) LINQ to SQL C#
I have a table called tblTrans it has 4 fields: ID, CustID, TDATE, Name
How can in in LINQ to SQL CE, get the newest or most recent row. I want the query to return all 开发者_如何学编程the fields for this row. I was trying this and could not get it to work:
tblTrans retTrans = (from c by c.TDATE into g orderby c.TDATE)
Try this:
var retTrans = (
from c in tblTrans
orderby c.TDATE descending
select c
).FirstOrDefault();
精彩评论