Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -2710,9 +2710,7 @@ public static IQueryable<TEntity> IgnoreQueryFilters<TEntity>(
Expression.Call(
instance: null,
method: IgnoreNamedQueryFiltersMethodInfo.MakeGenericMethod(typeof(TEntity)),
// converting the collection to an array if it isn't already one to ensure consistent caching. Fixes #37112.
// #37212 may be a possible future solution providing broader capabilities around parameterizing collections.
arguments: [source.Expression, Expression.Constant(filterKeys is string[] ? filterKeys : filterKeys.ToArray())]))
arguments: [source.Expression, Expression.Constant(filterKeys)]))
: source;

#endregion
Expand Down
28 changes: 26 additions & 2 deletions src/EFCore/Query/ExpressionEqualityComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ public int GetHashCode(Expression obj)
hash.Add(structuralEquatable.GetHashCode(StructuralComparisons.StructuralEqualityComparer));
break;

case IEnumerable enumerable:
foreach (var item in enumerable)
{
hash.Add(item?.GetHashCode() ?? 0);
}
break;

default:
hash.Add(constantExpression.Value);
break;
Expand Down Expand Up @@ -368,8 +375,25 @@ private static bool CompareConstant(ConstantExpression a, ConstantExpression b)
{
var (v1, v2) = (a.Value, b.Value);

return Equals(v1, v2)
|| (v1 is IStructuralEquatable array1 && array1.Equals(v2, StructuralComparisons.StructuralEqualityComparer));
if (Equals(v1, v2))
{
return true;
}

if (v1 is IStructuralEquatable structuralEquatable1)
{
if (structuralEquatable1.Equals(v2, StructuralComparisons.StructuralEqualityComparer))
{
return true;
}
}

if (v1 is IEnumerable enumerable1 && v2 is IEnumerable enumerable2)
{
return enumerable1.Cast<object?>().SequenceEqual(enumerable2.Cast<object?>());
}

return false;
}

private bool CompareGoto(GotoExpression a, GotoExpression b)
Expand Down