If his name were Patton or Eisenhower would it matter during wartime? Think B.J./Mary Jo during peacetime.
I am not naive, and not immune the the siren call of beauty or easy access to something that throws itself at you, but... as an officer you know that there are plenty of other opportunities and you don't mess with the lives of the men under your command. It just makes a mess of things.
Imagine if it were discovered that Trump was having an affair with the wife of one of the DOJ attorneys trying to get him. He would have to pack up and move to Russia at that point. Some messes you don't make for yourself if you are half-way intelligent.