In those cases your lambda is going to have to be smarter and have a conditional for what kind of object is returned.

One other option would be to always have the lambda recieve the id instead of the object in all cases.