/// <summary> /// This method returns 'true' when the expression doesn't reference any parameters /// from outside the scope of the expression. /// </summary> static public bool IsIndependent(Expression expression) { var v = new DependenceChecker(); v.Visit(expression); return(v.isIndependent); }
internal override Expression Visit(Expression expression) { if (expression == null) { return(null); } bool saveIsRemote = this.isRemote; switch (expression.NodeType) { case (ExpressionType)InternalExpressionType.Known: return(expression); case (ExpressionType)ExpressionType.Constant: break; default: this.isRemote = false; base.Visit(expression); if (!this.isRemote && expression.NodeType != ExpressionType.Lambda && expression.NodeType != ExpressionType.Quote && DependenceChecker.IsIndependent(expression)) { this.locals[expression] = true; // Not 'Add' because the same expression may exist in the tree twice. } break; } if (typeof(ITable).IsAssignableFrom(expression.Type) || typeof(DataContext).IsAssignableFrom(expression.Type)) { this.isRemote = true; } this.isRemote |= saveIsRemote; return(expression); }
/// <summary> /// This method returns 'true' when the expression doesn't reference any parameters /// from outside the scope of the expression. /// </summary> static public bool IsIndependent(Expression expression) { var v = new DependenceChecker(); v.Visit(expression); return v.isIndependent; }