The collection contains keys and values. But I was iterating through the Values collection which contained objects of type Invoice, so that's why I was getting that error.

Thanks a lot,