Right now I’m doing this, but I don’t like it very much:
decimal maxId = 0d;
try
{
maxId = ent.SaveStates.Max(c => c.Id);
}
catch (Exception ex) //no entries in the db
{
maxId = 1;
}
Is there a better way to handle nulls from the DB with entity-framework?
Here’s this:
I don’t think that will cause two queries, but I’d profile it to make sure.