I have a list of DTO received from a DB, and they have an ID. I want to ensure that my list contains an object with a specified ID. Apparently creating an object with expect
You requirement is not clear to me. When you say 'ensure that my list contains an object with a specified ID' do you want to:
Most responses have assumed you mean 1, however when thinking about it you could just as well mean 2 given the wording of the question. You could include the required result by altering your query:
SELECT * FROM employee WHERE firstname = 'John' OR id = 42;