Skip to content

Commit

Permalink
Do not override Equals
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMpn committed Dec 11, 2024
1 parent 5cb65f1 commit 70b6b38
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 33 deletions.
2 changes: 1 addition & 1 deletion MarkMpn.Sql4Cds.Engine/ExecutionPlan/FetchXmlScan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,7 @@ private object[] RemoveDuplicatedConditions(object[] items)
{
if (item is condition c)
{
if (newItems.OfType<condition>().Any(existing => existing.Equals(c)))
if (newItems.OfType<condition>().Any(existing => existing.IsSameAs(c)))
continue;
}

Expand Down
33 changes: 1 addition & 32 deletions MarkMpn.Sql4Cds.Engine/FetchXml.Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ partial class condition
[DefaultValue(false)]
public bool IsVariable { get; set; }

public override bool Equals(object obj)
public bool IsSameAs(condition other)
{
if (!(obj is condition other))
return false;

if (other.entityname != entityname ||
other.attribute != attribute ||
other.@operator != @operator ||
Expand Down Expand Up @@ -52,34 +49,6 @@ public override bool Equals(object obj)

return true;
}

public override int GetHashCode()
{
var hash = 0;
hash ^= entityname?.GetHashCode() ?? 0;
hash ^= attribute?.GetHashCode() ?? 0;
hash ^= @operator.GetHashCode();
hash ^= value?.GetHashCode() ?? 0;
hash ^= ValueOf?.GetHashCode() ?? 0;
hash ^= IsVariable.GetHashCode();
hash ^= aggregate.GetHashCode();
hash ^= aggregateSpecified.GetHashCode();
hash ^= alias?.GetHashCode() ?? 0;
hash ^= column?.GetHashCode() ?? 0;
hash ^= rowaggregate.GetHashCode();
hash ^= rowaggregateSpecified.GetHashCode();

if (Items != null)
{
foreach (var item in Items)
{
hash ^= item.Value?.GetHashCode() ?? 0;
hash ^= item.IsVariable.GetHashCode();
}
}

return hash;
}
}

partial class conditionValue
Expand Down

0 comments on commit 70b6b38

Please sign in to comment.