I have entity class:
[Serializable, Class(Table = "mon.tableView", Lazy = false)]
public class TableView
{
[CompositeId(1)]
[KeyProperty(2, Name = "column1", Column = "column1", TypeType = typeof(int))]
[KeyProperty(3, Name = "column2", Column = "column2", TypeType = typeof(int))]
internal int VirtualId { get; set; }
[Property(Column = "column1")]
private int column1 { get; set; }
[Property(Column = "column2")]
public int? column2 { get; set; }
[Property(Column = "column3")]
public int column3 { get; set; }
[Property(Column = "otherColumn")]
public string otherColumn{ get; set; }
public override bool Equals(object other)
{
if (this == other)
return true;
TableViewv dp = other as TableView;
if (vdp == null)
return false; // null or not a ReadOnlyUserRole
return column1.Equals(vdp.column1) ^ column2.Equals(vdp.column2) && column3.Equals(vdp.column3) && otherColumn.Equals(vdp.otherColumn); }
public override int GetHashCode()
{
return column1.GetHashCode() ^ column2.GetHashCode();
}
}
I know that GetHashCode() give 2 answers: - when 2 objects are not equal we know that are NOT equal. - when 2 objects are equal they might be equal but it's not for sure. Therefore there is Equal() method for this.
GetHashCode() method are giving me the same integer for 2 objects but I know other properties are not equal. When I get the list these objects i have few times duplicated object and my question is when Equals() method is called? Because I have never seen in debug mode when this method was called.