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
精彩评论