Cast database results to their expected type.