That is how anyone feels when a relationship that they invested a lot of themselves into doesn't work out. You put a lot of work into something and then it falls apart, and that hurts in a lot of ways. But do not blame yourself. As badkitty said, nothing that you did caused him to cheat. That's squarely on his losery shoulders.
Also don't think of the time you spent as wasted, either. What you have learned about yourself through this endeavor will make you wiser, and improve any future relationships you'll have, too.