There are always many ways of doing things but this is how I do it:
Object tempVal = CommandGenerationId.ExecuteScalar();
Int32 returnVal;
if (tempVal != null)
returnVal = Int32.Parse(tempVal);
Something along those lines. For me, this approach works better than trying to cram it into a single line.