开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜