I'm currently trying to calculate the expectation $E[g(X_K,K)]$ where $X_K$ is a continuous random variable with pdf $f_{X_K}$ and $K$ follows a beta-binomial distribution, more precisely, $P(K=k)=\int_{0}^{1} p^k(1-p)^{n-k}f_{\beta}(p)dp$ where $f_\beta$ denotes the pdf of the beta-distribution.
My approach is to consider
$E[g(X_K,K)]=\sum_{k=0}^{n} E[g(X_K,K)| K=k] P(K=k)$.
However, I'm not sure how to calculate $E[g(X_K,K)| K=k]$.
If the pdf $f_{X_k}$ is known, is it true that $E[g(X_K,K)| K=k] =\int g(x,k) f_{X_k}(x)dx$ ?
Thank you!