Skip to content

Commit 7d55aae

Browse files
committed
Merge pull request #157 from CV1/patch-2
Update src/FluentNHibernate/MappingModel/EqualityExtensions.cs
2 parents 705a055 + 06c20b7 commit 7d55aae

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/FluentNHibernate/MappingModel/EqualityExtensions.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ public static class EqualityExtensions
77
{
88
public static bool ContentEquals<TKey, TValue>(this IDictionary<TKey, TValue> left, IDictionary<TKey, TValue> right)
99
{
10-
if (left.Count() != right.Count())
10+
if (left.Count != right.Count)
1111
return false;
1212

13-
var index = 0;
1413
foreach (var item in left)
1514
{
16-
if (!item.Equals(right.ElementAt(index)))
17-
return false;
18-
19-
index++;
15+
var leftValue = item.Value;
16+
TValue rightValue;
17+
if (!right.TryGetValue(item.Key, out rightValue))
18+
return false; // Key mismatch
19+
if (!Equals(leftValue, rightValue))
20+
return false; // Value mismatch
2021
}
2122

2223
return true;

0 commit comments

Comments
 (0)