Only consider Id, but not ParentId for TreeNode equality checks

This commit is contained in:
ig 2023-03-08 13:28:22 +01:00
parent 702fa89914
commit e6fa2933b5
1 changed files with 3 additions and 5 deletions

View File

@ -4,9 +4,10 @@ namespace InnovEnergy.App.Backend.Model;
public abstract partial class TreeNode public abstract partial class TreeNode
{ {
// Note: Only consider Id, but not ParentId for TreeNode equality checks
protected Boolean Equals(TreeNode other) protected Boolean Equals(TreeNode other)
{ {
return Id == other.Id && ParentId == other.ParentId; return Id == other.Id;
} }
public override Boolean Equals(Object? obj) public override Boolean Equals(Object? obj)
@ -17,8 +18,5 @@ public abstract partial class TreeNode
} }
[SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")] [SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
public override Int32 GetHashCode() public override Int32 GetHashCode() => Id.GetHashCode();
{
return HashCode.Combine(Id, ParentId);
}
} }