Skip to content

Commit 6c5cf10

Browse files
y0ung3rroji
authored andcommitted
InMemoryTable: Make IsConcurrencyConflict() method more readable (dotnet#33561)
1 parent fa0973f commit 6c5cf10

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/EFCore.InMemory/Storage/Internal/InMemoryTable.cs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -229,29 +229,32 @@ private static bool IsConcurrencyConflict(
229229
object? rowValue,
230230
Dictionary<IProperty, object?> concurrencyConflicts)
231231
{
232-
if (property.IsConcurrencyToken)
232+
if (!property.IsConcurrencyToken)
233233
{
234-
var comparer = property.GetKeyValueComparer();
235-
var originalValue = entry.GetOriginalValue(property);
234+
return false;
235+
}
236236

237-
var converter = property.GetValueConverter()
238-
?? property.FindTypeMapping()?.Converter;
237+
var comparer = property.GetKeyValueComparer()
238+
?? StructuralComparisons.StructuralEqualityComparer;
239239

240-
if (converter != null)
241-
{
242-
rowValue = converter.ConvertFromProvider(rowValue);
243-
}
240+
var originalValue = entry.GetOriginalValue(property);
244241

245-
if ((comparer != null && !comparer.Equals(rowValue, originalValue))
246-
|| (comparer == null && !StructuralComparisons.StructuralEqualityComparer.Equals(rowValue, originalValue)))
247-
{
248-
concurrencyConflicts.Add(property, rowValue);
242+
var converter = property.GetValueConverter()
243+
?? property.FindTypeMapping()?.Converter;
249244

250-
return true;
251-
}
245+
if (converter != null)
246+
{
247+
rowValue = converter.ConvertFromProvider(rowValue);
252248
}
253249

254-
return false;
250+
if (comparer.Equals(rowValue, originalValue))
251+
{
252+
return false;
253+
}
254+
255+
concurrencyConflicts.Add(property, rowValue);
256+
257+
return true;
255258
}
256259

257260
/// <summary>

0 commit comments

Comments
 (0)