Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/EFCore/ChangeTracking/ValueComparer`.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,18 @@ public override LambdaExpression ObjectEqualsExpression
var left = Parameter(typeof(object), "left");
var right = Parameter(typeof(object), "right");

var remappedEquals = ReplacingExpressionVisitor.Replace(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, although I wonder if we are sometimes doing work (casts and comparisons) here that we don't need to do in some cases. I will add a note to #29909, which is about perf improvements in this area.

EqualsExpression.Parameters.ToList(),
[Convert(left, typeof(T)), Convert(right, typeof(T))],
EqualsExpression.Body);

_objectEqualsExpression = Lambda<Func<object?, object?, bool>>(
Condition(
Equal(left, Constant(null)),
Equal(right, Constant(null)),
AndAlso(
NotEqual(right, Constant(null)),
Invoke(
EqualsExpression,
Convert(left, typeof(T)),
Convert(right, typeof(T))))),
remappedEquals)),
left,
right);
}
Expand Down