int id; object objId = reader["id"]; if (objId is long) { id = (int)(long)objId; } else { id = (int)objId; }