Solenoid and compressor