If you dreamed you had an affair, the dream interpretation depends on what is going on in your waking life.
If you had been spending a lot of time on your work, and less time on your significant other and family, you are having an affair with your work.
If you have not been busy at work, then the dream interpretation of having an affair means you are dissatisfied with your intimacy with your partner. As a consequence, you dreamed of having an affair to satisfy your frustrations with your sex life.
If you were thinking of making changes to your family responsibilities, or other areas of your control, it may seem like you are abandoning your responsibilities. Expressed as a metaphor, it seems like you are having an affair to escape your responsibilities.
If you have a best friend who is not your romantic partner, you might dream of this person as the one with whom you are having an affair with.