Benny Sutton is 4 hire - just click here
Null handling Integers
Always return an int or 0 (if null)
public static int NZ_IntOrDefault(this object target)
{
int valueToReturn = default(int);
string parseValue = target != null ? target.ToString() : valueToReturn.ToString();
int.TryParse(parseValue, out valueToReturn);
return valueToReturn;
}
call like this...
db.Entry(photo).Property("PlaceID").CurrentValue.NZ_IntOrDefault()