For an ideal gas, we can write the internal energy, U, as a function of temperature and volume.

U = U(T,V)

From this expression, we can obtain the following differential:

dU = (dU/dT)_{v}dT + (dU/dV)_{T}dV

Note that C_{v} = (dU/dT)_{v} by definition.

In addition, (dU/dV)_{T} = 0 because the internal energy of an ideal gas depends only on its temperature.

Therefore, we get:

dU = C_{v}dT

This equation works in all cases (but only for ideal gases. If (dU/dV)_{T} is not zero, this does not hold).

dq = C_{v}dT is only valid for constant pressure processes, however.