Skip to content

Commit

Permalink
Add convert node to snapshot expression when needed (#25936)
Browse files Browse the repository at this point in the history
Fixes #25259
  • Loading branch information
ajcvickers committed Sep 8, 2021
1 parent eb30e30 commit 4f38f2a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/EFCore/ChangeTracking/Internal/SnapshotFactoryFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ private Expression CreateSnapshotValueExpression(Expression expression, IPropert
expression,
comparer.SnapshotExpression.Body);

if (snapshotExpression.Type != propertyBase.ClrType)
{
snapshotExpression = Expression.Convert(snapshotExpression, propertyBase.ClrType);
}

expression = propertyBase.ClrType.IsNullableType()
? Expression.Condition(
Expression.Equal(expression, Expression.Constant(null, propertyBase.ClrType)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
new ValueComparer<IDictionary<string, string>>(
(v1, v2) => v1.SequenceEqual(v2),
v => v.GetHashCode(),
v => (IDictionary<string, string>)new Dictionary<string, string>(v)));
v => new Dictionary<string, string>(v)));
});

var urlConverter = new UrlSchemeRemover();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ public EnumerableOfIntComparer()
: base(
(c1, c2) => (c1 == null && c2 == null) || (c1 != null && c2 != null && c1.SequenceEqual(c2)),
c => c == null ? 0 : c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
c => c == null ? null : (IEnumerable<int>)c.ToList())
c => c == null ? null : c.ToList())
{
}
}
Expand Down

0 comments on commit 4f38f2a

Please sign in to comment.