I have a table called Picture in my database. I’m using the primary key of that table as the filenames for the pictures.
When creating a new picture I need it to follow a logical sequence. For this I’m using the primary key.
How can I get the highest value of the primary key for this table?
Picture table has these columns: ID, IDProject (foreign key). I just need to get the highest ID number.
You’ll want to use the
Enumerable.Max()method, which “returns the maximum value in a sequence of values.” For example, finding the highest picture ID:Also, see this article on MSDN (“Find the Maximum Value in a Numeric Sequence”).