I would like to return the max Id from a table using Dapper.net
var x = connection.Query<int>("SELECT max(val) FROM info").FirstOrDefault();
This works - unless no row exists then I get an
Object reference not set to an instance of an object.
Shouldn't the 'OrDefault' mean this returns 0 when no records are present?
How can I return 0 - or some non null value to prevent a crash.
thx