Hi Robert....welcome to the forum! As you said, because the problem is intermittent and can also be caused by a variety of factors like the fuel pump or various sensors; I would recommend getting the codes read if you're able to. It'll give you a good starting place to evaluate the issue. Lastly, I'm attaching a link to our site's tech articles, check them out when you need to troubleshoot or fix an issue. Best of luck!
E90 BMW Tech Articles -
BMW 3-Series E90 (2006-2013) Technical Articles - Pelican Parts
-Dmitry