- Code: Select all
public override bool Equals( object obj )
{
if( this == obj )
return true;
if( ( obj == null ) || ( obj.GetType() != this.GetType() ) )
return false;
CreditAppStipulation castObj = (CreditAppStipulation)obj;
return ( castObj != null ) &&
( this.m_castipid == castObj.CaStipId );
}
The problem is that with NHibernate 2.0 you have the introduction of Proxy objects and the second if test will not always work. In my case, I had a situation where I had a regular POCO and a proxy for a CreditAppStipulation object. It took me a while to track down that my objects weren't testing as equal because the GetType() methods were returning two different type values
So, what I did was change my equals tests to use the following format:
- Code: Select all
public override bool Equals(object obj)
{
if (this == obj) return true;
CreditAppStipulation castObj = obj as CreditAppStipulation;
return (castObj != null) &&
(this.m_castipid == castObj.CaStipId);
}
This seems to take care of the problem I was having. I thought I would share it in case any of the template owners or users might find it helpful.
Pat
