System.Data.Common.CommandTrees.DbExpression.Accept(System.Data.Common.CommandTrees.DbExpressionVisitor)

Here are the examples of the csharp api class System.Data.Common.CommandTrees.DbExpression.Accept(System.Data.Common.CommandTrees.DbExpressionVisitor) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

139 Examples 7

1. Example

Project: referencesource
Source File: ExpressionDumper.cs
internal void Dump(DbExpression target)
        {
            target.Accept(this);
        }

2. Example

Project: referencesource
Source File: ExpressionKeyGen.cs
internal static bool TryGenerateKey(DbExpression tree, out string key)
        {
            var keyGen = new ExpressionKeyGen();
            try
            {
                tree.Accept(keyGen);
                key = keyGen._key.ToString();
                return true;
            }
            catch (NotSupportedException)
            {
                key = null;
                return false;
            }
        }

3. Example

Project: referencesource
Source File: ExpressionPrinter.cs
internal TreeNode VisitExpression(DbExpression expr)
            {
                return expr.Accept<TreeNode>(this);
            }

4. Example

Project: referencesource
Source File: ExpressionPrinter.cs
internal TreeNode VisitExpression(string name, DbExpression expr)
            {
                return new TreeNode(name, expr.Accept<TreeNode>(this));
            }

5. Example

Project: referencesource
Source File: DbSetClause.cs
internal override TreeNode Print(DbExpressionVisitor<TreeNode> visitor)
        {
            TreeNode node = new TreeNode("DbSetClause");
            if (null != this.Property)
            {
                node.Children.Add(new TreeNode("Property", this.Property.Accept(visitor)));
            }
            if (null != this.Value)
            {
                node.Children.Add(new TreeNode("Value", this.Value.Accept(visitor)));
            }
            return node;
        }

6. Example

Project: referencesource
Source File: DefaultExpressionVisitor.cs
protected virtual DbExpression VisitExpression(DbExpression expression)
        {
            DbExpression newValue = null;
            if (expression != null)
            {
                newValue = expression.Accept<DbExpression>(this);
            }
            
            return newValue;
        }

7. Example

Project: referencesource
Source File: Propagator.cs
static internal ChangeNode Propagate(UpdateTranslator parent, EntitySet table, DbQueryCommandTree umView)
        {
            // Construct a new instance of a propagator, which implements a visitor interface
            // for expression nodes (nodes in the update mapping view) and returns changes nodes
            // (seeded by C-Space extent changes returned by the grouper).
            DbExpressionVisitor<ChangeNode> propagator = new Propagator(parent, table);

            // Walk the update mapping view using the visitor pattern implemented in this class.
            // The update mapping view describes the S-Space table we're targeting, so the result
            // returned for the root of view corresponds to changes propagated to the S-Space. 
            return umView.Query.Accept(propagator);
        }

8. Example

Project: referencesource
Source File: Propagator.Evaluator.cs
static internal PropagatorResult Evaluate(DbExpression node, PropagatorResult row, Propagator parent)
            {
                DbExpressionVisitor<PropagatorResult> evaluator = new Evaluator(row, parent);
                return node.Accept(evaluator);
            }

9. Example

Project: referencesource
Source File: ViewValidator.cs
internal DbExpressionEntitySetInfo VisitExpression(DbExpression expression)
            {
                return expression.Accept(this);
            }

10. Example

Project: referencesource
Source File: ITreeGenerator.cs
private Node VisitExpr(DbExpression e)
        {
            if (e == null)
            {
                return null;
            }
            else
            {
                return e.Accept<Node>(this);
            }
        }

11. Example

Project: referencesource
Source File: DmlSqlGenerator.cs
internal static string GenerateDeleteSql(DbDeleteCommandTree tree, SqlVersion sqlVersion, out List<SqlParameter> parameters)
        {
            StringBuilder commandText = new StringBuilder(s_commandTextBuilderInitialCapacity);
            ExpressionTranslator translator = new ExpressionTranslator(commandText, tree, false, sqlVersion);

            // delete [schemaName].[tableName]
            commandText.Append("delete ");
            tree.Target.Expression.Accept(translator);
            commandText.AppendLine();
            
            // where c1 = ... AND c2 = ...
            commandText.Append("where ");
            tree.Predicate.Accept(translator);

            parameters = translator.Parameters;
            return commandText.ToString();
        }

12. Example

Project: referencesource
Source File: DmlSqlGenerator.cs
public override void Visit(DbIsNullExpression expression)
            {
                expression.Argument.Accept(this);
                _commandText.Append(" is null");
            }

13. Example

Project: referencesource
Source File: DmlSqlGenerator.cs
public override void Visit(DbNewInstanceExpression expression)
            {
                // assumes all arguments are self-describing (no need to use aliases
                // because no renames are ever used in the projection)
                bool first = true;
                foreach (DbExpression argument in expression.Arguments)
                {
                    if (first) { first = false; }
                    else { _commandText.Append(", "); }
                    argument.Accept(this);
                }
            }

14. Example

Project: referencesource
Source File: DmlSqlGenerator.cs
private void VisitBinary(DbBinaryExpression expression, string separator)
            {
                _commandText.Append("(");
                expression.Left.Accept(this);
                _commandText.Append(separator);
                expression.Right.Accept(this);
                _commandText.Append(")");
            }

15. Example

Project: referencesource
Source File: Sql8ConformanceChecker.cs
internal static bool NeedsRewrite(DbExpression expr)
        {
            Sql8ConformanceChecker checker = new Sql8ConformanceChecker();
            return expr.Accept(checker);
        }

16. Example

Project: referencesource
Source File: Sql8ConformanceChecker.cs
private bool VisitExpression(DbExpression expression)
        {
            if (expression == null)
            {
                return false;
            }
            return expression.Accept(this);
        }

17. Example

Project: mysql-connector-net
Source File: DeleteGenerator.cs
public override string GenerateSQL(DbCommandTree tree)
    {
      DbDeleteCommandTree commandTree = tree as DbDeleteCommandTree;

      DeleteStatement statement = new DeleteStatement();

      statement.Target = commandTree.Target.Expression.Accept(this);
      scope.Add("target", statement.Target as InputFragment);

      statement.Where = commandTree.Predicate.Accept(this);

      return statement.ToString();
    }

18. Example

Project: mysql-connector-net
Source File: SqlGenerator.cs
public override SqlFragment Visit(DbIsEmptyExpression expression)
    {
      ExistsFragment f = new ExistsFragment(expression.Argument.Accept(this));
      f.Negate();
      return f;
    }

19. Example

Project: mysql-connector-net
Source File: SqlGenerator.cs
public override SqlFragment Visit(DbCastExpression expression)
    {
      //TODO: handle casting
      return expression.Argument.Accept(this);
    }

20. Example

Project: mysql-connector-net
Source File: SqlGenerator.cs
public override SqlFragment Visit(DbLikeExpression expression)
    {
      LikeFragment f = new LikeFragment();

      f.Argument = expression.Argument.Accept(this);
      f.Pattern = expression.Pattern.Accept(this);      

      return f;
    }

21. Example

Project: mysql-connector-net
Source File: SqlGenerator.cs
public override SqlFragment Visit(DbIsNullExpression expression)
    {
      IsNullFragment f = new IsNullFragment();
      f.Argument = expression.Argument.Accept(this);
      return f;
    }

22. Example

Project: mysql-connector-net
Source File: UpdateGenerator.cs
protected override SelectStatement GenerateReturningSql(DbModificationCommandTree tree, DbExpression returning)
    {
      SelectStatement select = base.GenerateReturningSql(tree, returning);
      ListFragment where = new ListFragment();
      where.Append(" row_count() > 0 and ");
      where.Append( ((DbUpdateCommandTree)tree).Predicate.Accept(this) );
      select.Where = where;

      return select;
    }

23. Example

Project: referencesource
Source File: ExpressionKeyGen.cs
private void VisitBinding(DbExpressionBinding binding)
        {
            _key.Append("BV");
            VisitVariableName(binding.VariableName);
            _key.Append("=(");
            binding.Expression.Accept(this);
            _key.Append(')');
        }

24. Example

Project: referencesource
Source File: ExpressionKeyGen.cs
private void VisitGroupBinding(DbGroupExpressionBinding groupBinding)
        {
            _key.Append("GBVV");
            VisitVariableName(groupBinding.VariableName);
            _key.Append(",");
            VisitVariableName(groupBinding.GroupVariableName);
            _key.Append("=(");
            groupBinding.Expression.Accept(this);
            _key.Append(')');
        }

25. Example

Project: referencesource
Source File: ExpressionKeyGen.cs
private void VisitUnary(DbUnaryExpression expr)
        {
            VisitExprKind(expr.ExpressionKind);
            _key.Append('(');
            expr.Argument.Accept(this);
            _key.Append(')');
        }

26. Example

Project: referencesource
Source File: ExpressionKeyGen.cs
private void VisitBinary(DbBinaryExpression expr)
        {
            VisitExprKind(expr.ExpressionKind);
            _key.Append('(');
            expr.Left.Accept(this);
            _key.Append(',');
            expr.Right.Accept(this);
            _key.Append(')');
        }

27. Example

Project: referencesource
Source File: ExpressionKeyGen.cs
private void VisitCastOrTreat(DbUnaryExpression e)
        {
            VisitExprKind(e.ExpressionKind);
            _key.Append('(');
            e.Argument.Accept(this);
            _key.Append(":");
            _key.Append(e.ResultType.Identity);
            _key.Append(')');
        }

28. Example

Project: referencesource
Source File: ExpressionKeyGen.cs
public override void Visit(DbLambdaExpression expression)
        {
            _key.Append("Lambda(");
            foreach (var v in expression.Lambda.Variables)
            {
                _key.Append("(V");
                VisitVariableName(v.VariableName);
                _key.Append(":");
                _key.Append(v.ResultType.Identity);
                _key.Append(')');
            }
            _key.Append("=");
            foreach (var a in expression.Arguments)
            {
                _key.Append('(');
                a.Accept(this);
                _key.Append(')');
            }
            _key.Append(")Body(");
            expression.Lambda.Body.Accept(this);
            _key.Append(")");
        }

29. Example

Project: referencesource
Source File: ExpressionKeyGen.cs
public override void Visit(DbPropertyExpression e)
        {
            e.Instance.Accept(this);
            VisitExprKind(e.ExpressionKind);
            _key.Append(e.Property.Name);
        }

30. Example

Project: referencesource
Source File: ExpressionKeyGen.cs
public override void Visit(DbLikeExpression e)
        {
            VisitExprKind(e.ExpressionKind);
            _key.Append('(');
            e.Argument.Accept(this);
            _key.Append(")(");
            e.Pattern.Accept(this);
            _key.Append(")(");
            if (e.Escape != null)
            {
                e.Escape.Accept(this);
            }
            e.Argument.Accept(this);
            _key.Append(')');
        }

31. Example

Project: referencesource
Source File: ExpressionKeyGen.cs
public override void Visit(DbLimitExpression e)
        {
            VisitExprKind(e.ExpressionKind);
            if (e.WithTies)
            {
                _key.Append("WithTies");
            }
            _key.Append('(');
            e.Argument.Accept(this);
            _key.Append(")(");
            e.Limit.Accept(this);
            _key.Append(')');
        }

32. Example

Project: referencesource
Source File: ExpressionKeyGen.cs
public override void Visit(DbIsOfExpression e)
        {
            VisitExprKind(e.ExpressionKind);
            _key.Append('(');
            e.Argument.Accept(this);
            _key.Append(":");
            _key.Append(e.OfType.EdmType.Identity);
            _key.Append(')');
        }

33. Example

Project: referencesource
Source File: ExpressionKeyGen.cs
public override void Visit(DbOfTypeExpression e)
        {
            VisitExprKind(e.ExpressionKind);
            _key.Append('(');
            e.Argument.Accept(this);
            _key.Append(":");
            _key.Append(e.OfType.EdmType.Identity);
            _key.Append(')');
        }

34. Example

Project: referencesource
Source File: ExpressionKeyGen.cs
public override void Visit(DbCaseExpression e)
        {
            VisitExprKind(e.ExpressionKind);
            _key.Append('(');
            for (int idx = 0; idx < e.When.Count; idx++)
            {
                _key.Append("WHEN:(");
                e.When[idx].Accept(this);
                _key.Append(")THEN:(");
                e.Then[idx].Accept(this);
            }
            _key.Append("ELSE:(");
            e.Else.Accept(this);
            _key.Append("))");
        }

35. Example

Project: referencesource
Source File: ExpressionKeyGen.cs
public override void Visit(DbRefExpression e)
        {
            //
            VisitExprKind(e.ExpressionKind);
            _key.Append("(ESET(");
            _key.Append(e.EntitySet.EntityContainer.Name);
            _key.Append('.');
            _key.Append(e.EntitySet.Name);
            _key.Append(")T(");
            _key.Append(TypeHelpers.GetEdmType<RefType>(e.ResultType).ElementType.FullName);
            _key.Append(")(");
            e.Argument.Accept(this);
            _key.Append(')');
        }

36. Example

Project: referencesource
Source File: ExpressionKeyGen.cs
public override void Visit(DbRelationshipNavigationExpression e)
        {
            VisitExprKind(e.ExpressionKind);
            _key.Append('(');
            e.NavigationSource.Accept(this);
            _key.Append(")A(");
            _key.Append(e.NavigateFrom.DeclaringType.Identity);
            _key.Append(")(");
            _key.Append(e.NavigateFrom.Name);
            _key.Append("->");
            _key.Append(e.NavigateTo.Name);
            _key.Append("))");
        }

37. Example

Project: referencesource
Source File: Propagator.Evaluator.cs
internal static bool EvaluatePredicate(DbExpression predicate, PropagatorResult row, Propagator parent)
            {
                Evaluator evaluator = new Evaluator(row, parent);
                PropagatorResult expressionResult = predicate.Accept(evaluator);

                bool? result = ConvertResultToBool(expressionResult);

                // unknown --> false at base of predicate
                return result ?? false;
            }

38. Example

Project: referencesource
Source File: UpdateExpressionVisitor.cs
public override TReturn Visit(DbExpression expression)
        {
            if (null != expression)
            {
                return expression.Accept(this);
            }
            else
            {
                throw ConstructNotSupportedException(expression);
            }
        }

39. Example

Project: referencesource
Source File: DmlSqlGenerator.cs
internal static string GenerateUpdateSql(DbUpdateCommandTree tree, SqlVersion sqlVersion, out List&l/n ..... /n //View Source file for more details /n }

40. Example

Project: referencesource
Source File: SqlFunctionCallHandler.cs
private static void WriteFunctionArguments(SqlGenerator sqlgen, IEnumerable<DbExpression> functionArguments, SqlBuilder result)
        {
            result.Append("(");
            string separator = "";
            foreach (DbExpression arg in functionArguments)
            {
                result.Append(separator);
                result.Append(arg.Accept(sqlgen));
                separator = ", ";
            }
            result.Append(")");
        }

41. Example

Project: referencesource
Source File: SqlFunctionCallHandler.cs
private static void AppendConvertToVarchar(SqlGenerator sqlgen, SqlBuilder result, DbExpression e)
        {
            result.Append("convert(varchar(255), ");
            result.Append(e.Accept(sqlgen));
            result.Append(")");
        }

42. Example

Project: referencesource
Source File: SqlFunctionCallHandler.cs
private static ISqlFragment HandleCanonicalFunctionDateAdd(SqlGenerator sqlgen, DbFunctionExpression e)
        {
            SqlBuilder result = new SqlBuilder();

            result.Append("DATEADD (");
            result.Append(_dateAddFunctionNameToDatepartDictionary[e.Function.Name]);
            result.Append(", ");
            result.Append(e.Arguments[1].Accept(sqlgen));
            result.Append(", ");
            result.Append(e.Arguments[0].Accept(sqlgen));
            result.Append(")");

            return result;
        }

43. Example

Project: referencesource
Source File: SqlFunctionCallHandler.cs
private static ISqlFragment HandleCanonicalFunctionDateDiff(SqlGenerator sqlgen, DbFunctionExpression e)
        {
            SqlBuilder result = new SqlBuilder();

            result.Append("DATEDIFF (");
            result.Append(_dateDiffFunctionNameToDatepartDictionary[e.Function.Name]);
            result.Append(", ");
            result.Append(e.Arguments[0].Accept(sqlgen));
            result.Append(", ");
            result.Append(e.Arguments[1].Accept(sqlgen));
            result.Append(")");

            return result;
        }

44. Example

Project: referencesource
Source File: SqlGenerator.cs
private SqlSelectStatement VisitInputExpression(DbExpression inputExpression,
            string inp/n ..... /n //View Source file for more details /n }

45. Example

Project: referencesource
Source File: SqlGenerator.cs
private SqlBuilder VisitIsNullExpression(DbIsNullExpression e, bool negate)
        {
            SqlBuilder result = new SqlBuilder();
            if (e.Argument.ExpressionKind == DbExpressionKind.ParameterReference)
            {
                _ignoreForceNonUnicodeFlag = true;
            }
            result.Append(e.Argument.Accept(this));
            // reset flag, it is not possible to reach this function with this flag set to true.
            _ignoreForceNonUnicodeFlag = false;
            if (!negate)
            {
                result.Append(" IS NULL");
            }
            else
            {
                result.Append(" IS NOT NULL");
            }

            return result;
        }

46. Example

Project: referencesource
Source File: SqlGenerator.cs
private ISqlFragment HandleCountExpression(DbExpression e)
        {
            ISqlFragment result;

            if (e.ExpressionKind == DbExpressionKind.Constant)
            {
                //For constant expression we should not cast the value, 
                // thus we don't go throught the default DbConstantExpression handling
                SqlBuilder sqlBuilder = new SqlBuilder();
                sqlBuilder.Append(((DbConstantExpression)e).Value.ToString());
                result = sqlBuilder;
            }
            else
            {
                result = e.Accept(this);
            }

            return result;
        }

47. Example

Project: mysql-connector-net
Source File: FunctionFragment.cs
private SqlFragment GenericFunction(Dictionary<string,string> funcs, 
            DbFunctionExpression e)
        {
            SqlFragment[] frags = new SqlFragment[e.Arguments.Count];

            for (int i=0; i < e.Arguments.Count; i++)
                frags[i] = e.Arguments[i].Accept(callingGenerator);

            string sql = String.Format(funcs[e.Function.Name], frags);
            return new LiteralFragment(sql);
        }

48. Example

Project: mysql-connector-net
Source File: FunctionProcessor.cs
private SqlFragment UserDefinedFunction(DbFunctionExpression e)
    {
      FunctionFragment f = new FunctionFragment();
      f.Name = Metadata.TryGetValueMetadataProperty<string>(e.Function,
          "StoreFunctionNameAttribute");

      if (String.IsNullOrEmpty(f.Name))
        f.Name = e.Function.Name;

      f.Quoted = !Metadata.TryGetValueMetadataProperty<bool>(e.Function, "BuiltInAttribute");

      bool isFuncNiladic = Metadata.TryGetValueMetadataProperty<bool>(e.Function, "NiladicFunctionAttribute");
      if (isFuncNiladic && e.Arguments.Count > 0)
        throw new InvalidOperationException("Niladic functions cannot have parameters");

      ListFragment list = new ListFragment();
      string delimiter = "";
      foreach (DbExpression arg in e.Arguments)
      {
        if (delimiter.Length > 0)
          list.Append(new LiteralFragment(delimiter));
        list.Append(arg.Accept(callingGenerator));
        delimiter = ", ";
      }
      f.Argument = list;

      return f;
    }

49. Example

Project: mysql-connector-net
Source File: InsertGenerator.cs
public override string GenerateSQL(DbCommandTree tree)
    {
      DbInsertCommandTree commandTree = tree as DbInsertCommandTree;

      InsertStatement statement = new InsertStatement();

      DbExpressionBinding e = commandTree.Target;
      statement.Target = (InputFragment)e.Expression.Accept(this);

      scope.Add("target", statement.Target);

      foreach (DbSetClause setClause in commandTree.SetClauses)
        statement.Sets.Add(setClause.Property.Accept(this));

      if (values == null)
        values = new Dictionary<EdmMember, SqlFragment>();

      foreach (DbSetClause setClause in commandTree.SetClauses)
      {
        DbExpression value = setClause.Value;
        SqlFragment valueFragment = value.Accept(this);
        statement.Values.Add(valueFragment);

        if (value.ExpressionKind != DbExpressionKind.Null)
        {
          EdmMember property = ((DbPropertyExpression)setClause.Property).Property;
          values.Add(property, valueFragment);
        }
      }

      if (commandTree.Returning != null)
        statement.ReturningSelect = GenerateReturningSql(commandTree, commandTree.Returning);

      return statement.ToString();
    }

50. Example

Project: mysql-connector-net
Source File: SelectGenerator.cs
private SqlFragment HandleJoinExpression(DbExpressionBinding left, DbExpressionBinding right,
        DbExpressionKind joinType, DbExpression joinCondition)
    {
      JoinFragment join = new JoinFragment();
      join.JoinType = Metadata.GetOperator(joinType);

      join.Left = VisitInputExpression(left.Expression, left.VariableName, left.VariableType);
      join.Left = WrapJoinInputIfNecessary(join.Left, false);

      join.Right = VisitInputExpression(right.Expression, right.VariableName, right.VariableType);
      join.Right = WrapJoinInputIfNecessary(join.Right, true);

      if (join.Right is SelectStatement)
      {
        SelectStatement select = join.Right as SelectStatement;
        if (select.IsWrapped)
          select.Name = right.VariableName;
      }

      // now handle the ON case
      if (joinCondition != null)
        join.Condition = joinCondition.Accept(this);
      return join;
    }