开发者

How to get the max row number from a table by using linq

SELECT ISNULL(MAX(ColumnName) + 1, 1) AS ColumnName 
FROM TableName

How to write this query in LINQ.Is there any way to convert sql to linq . i want a converter.

Above query works well but i want the same output on linq .How to ?

I know how to select max

  var products = ((from p in db.TableName
                 开发者_高级运维           select p.ColumnName).Max());


This should do it:

return (myContext.MyTable.Max(t => (int?) t.MyColumn) ?? 0) + 1
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜