All, I have a system setup to generate proxies based on an interface. This causes me a problem when I use the standard collection compare methods (e.g. Contains(obj), Remove(obj) etc.)
If I pass a proxy'd object to a collection Remove method (where the collection is a generic type of the concrete version of the proxy), then the remove will not find the matching concrete type in the collection that the proxy represents and remove it..... i.e. the object I want to remove doesn't get removed. I thought'd I'd got round it by overriding the equals method of my entities (which all inherit from a base class) so that they all did a compare on the ID. Therefore if proxy ID = concrete type ID then there is a match and the object is removed from the collection. By keeping it to ID (and ignoring the cases of where the proxy isn't saved yet so there is no id) I can use the proxy without forcing a load. Therefore I don't really want to compare all the properties of the object, as this will force a load. Unfortunately this (or any other custom compare solution I suspect) doesn't work as the proxy (based on an interface, not a concrete type) generated by NH doesn't know anything about my base class or how I want to compare objects for equality. Therefore it's doing an "is this object the same as this proxy" and returning false, when in fact, they represent the same thing. In the end I need to find the object in the collection by ID, then use the found object to do the remove. It's a bit of a pain to do this, isn't particularly intuitive and easy to forget, especially for other developers. This is part of an app. framework so I'd like a solution I can put in one place and other developers don't have to worry about it. I was thinking of somehow overriding how NH proxies perform equality, but I suspect this could be difficult. Has anybody any advice or solutions? -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
