MAX MIN functions

Sep 24, 2010 at 9:49 AM


is there a way to use Max/Min functions within the DB? For example:

I have a table with 2 fields: ID (int), Name (string)

I have to insert a new item in a table and I need to know the max ID in the table, so I can insert the new item with a ID greater than the max value already present.



Sep 30, 2010 at 10:15 PM

Did you figure this out?  If so, please let us know, otherwise try using GUIDs instead.

Generate a new guid for the id when you create and insert the record.  Use GUID as the datatype if it supports it or use a string and convert the guid to a string?

Oct 1, 2010 at 2:27 AM

This should be pretty easy with Linq.  Make sure to add using System.Linq to your code file.

Then you can do something like

if (db.Table<Thing>().COunt()>0)


return (from one in db.Table<Thing>() select one.ID).Max()




return 1;