Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How go get max value of a unique id column using LINQ

How can I write this in the simplest way using LINQ?

SELECT        MAX(Game_id) AS MaxValue
FROM          Dim_Game
like image 251
JF Beaulieu Avatar asked Dec 18 '11 02:12

JF Beaulieu


People also ask

How do I find the maximum value of a column in LINQ?

In LINQ, you can find the maximum element of the given sequence by using Max() function. This method provides the maximum element of the given set of values.

What is Max in Linq?

Max () function in LINQ is used to return the maximum value from the collection. With the help of Max() function, it is easy to find the maximum value from a given data source using Max () function. In the other case, we have to write the code to get the maximum value from the list of values.


1 Answers

Try context.Dim_Games.Max(g => g.Game_id);

like image 89
Sergey Kalinichenko Avatar answered Sep 30 '22 13:09

Sergey Kalinichenko