I can not understand what the performance of the method Equals() and GetHashCode(). At what time I can use one or the other, or under what conditions.
I can't seem to find examples on how to implement them in the context of NHibernate.
I can not understand what the performance of the method Equals() and GetHashCode(). At what time I can use one or the other, or under what conditions.
I can't seem to find examples on how to implement them in the context of NHibernate.
 
    
    because there is a tag NHibernate the OP propably wants NHibernate specific. so here is a base class for persisted entities which implements Equals() and GetHashcCode()
public abstract class Entity
{
    public virtual long Id { get; protected set; }
    public override bool Equals(object obj)
    {
        var other = obj as Entity;
        return other != null && (Id == 0 ? ReferenceEquals(this, other) : Id == other.Id);
    }
    public override int GetHashCode()
    {
        return Id.GetHashCode();
    }
}
