src/Shared/EntityFramework.SqlServer/SqlGen/Sql8ExpressionRewriter.cs
// <summary>
// Determines whether two expressions match.
// They match if they are  of the shape
// expr1 -> DbPropertyExpression(... (DbPropertyExpression(DbVariableReferenceExpression(expr1BindingVariableName), nameX), ..., name1)
// expr1 -> DbPropertyExpression(... (DbPropertyExpression(DbVariableReferenceExpression(expr2BindingVariableName), nameX), ..., name1),
// i.e. if they only differ in the name of the binding.
// </summary>
Determines whether two expressions match.
They match if they are  of the shape
expr1 -> DbPropertyExpression(...
Determines whether two expressions match . They match if they are of the shape expr1 - > DbPropertyExpression ( ...
private static bool AreMatching(
            DbPropertyExpression expr1, DbPropertyExpression expr2, string expr1BindingVariableName, string expr2BindingVariableName)
        {
            if (expr1.Property.Name
                != expr2.Property.Name)
            {
                return false;
            }
            if (expr1.Instance.ExpressionKind
                != expr2.Instance.ExpressionKind)
            {
                return false;
            }
            if (expr1.Instance.ExpressionKind
                == DbExpressionKind.Property)
            {
                return AreMatching(
                    (DbPropertyExpression)expr1.Instance, (DbPropertyExpression)expr2.Instance, expr1BindingVariableName,
                    expr2BindingVariableName);
            }
            var instance1 = (DbVariableReferenceExpression)expr1.Instance;
            var instance2 = (DbVariableReferenceExpression)expr2.Instance;
            return (String.Equals(instance1.VariableName, expr1BindingVariableName, StringComparison.Ordinal)
                    && String.Equals(instance2.VariableName, expr2BindingVariableName, StringComparison.Ordinal));
        }
private static bool AreMatching ( DbPropertyExpression expr1 , DbPropertyExpression expr2 , string expr1BindingVariableName , string expr2BindingVariableName ) { if ( expr1 . Property . Name != expr2 . Property . Name ) { return false ; } if ( expr1 . Instance . ExpressionKind != expr2 . Instance . ExpressionKind ) { return false ; } if ( expr1 . Instance . ExpressionKind == DbExpressionKind . Property ) { return AreMatching ( ( DbPropertyExpression ) expr1 . Instance , ( DbPropertyExpression ) expr2 . Instance , expr1BindingVariableName , expr2BindingVariableName ) ; } var instance1 = ( DbVariableReferenceExpression ) expr1 . Instance ; var instance2 = ( DbVariableReferenceExpression ) expr2 . Instance ; return ( String . Equals ( instance1 . VariableName , expr1BindingVariableName , StringComparison . Ordinal ) && String . Equals ( instance2 . VariableName , expr2BindingVariableName , StringComparison . Ordinal ) ) ; }
Determines whether two expressions match.
Determines whether two expressions match .
expr1
DbPropertyExpression
expr2
DbPropertyExpression
expr1BindingVariableName
string
expr2BindingVariableName
string