Hadn't thought of the LINQ solution - thanks.
However, I'm struggling to fit this in to the context of an existing subdomain, and I don't know if I'm missing the point - hopefully you can clarify.
I presume the idea of subdomains is so with a single Persist() you can save all related changes within a single transaction so it all either works or fails. However, I've found it works in a different way to what I imagined.
Say I have loaded a collection of User objects already. As a result of my processing, I now need to find and edit another specific user using a custom select method. If I create a separate subdomain, I can do this and use your FirstOrDefault suggestion,
but then the Persist() for the initial subdomain won't save changes to this. If I use the existing subdomain, the User object returned (if one is actually returned) is now a part of the initial Users collection, in which case I can't use FirstOrDefault, and
I don't know whether the custom select command returned anything.
Have I misunderstood? If I already have a Users collection and want to call a custom select command to find either another single User, or another selection of Users, do I have to create a second subdomain and have two Persist() commands (thereby losing
a single transaction), or is there a way to keep it all in a single transaction but still identify separately the User(s) loaded by the second select command?
Thanks for your help - hope that makes sense...