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
0
0
2. Example
View licenseinternal 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; } }
0
3. Example
View licenseinternal TreeNode VisitExpression(DbExpression expr) { return expr.Accept<TreeNode>(this); }
0
4. Example
View licenseinternal TreeNode VisitExpression(string name, DbExpression expr) { return new TreeNode(name, expr.Accept<TreeNode>(this)); }
0
5. Example
View licenseinternal 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; }
0
6. Example
View licenseprotected virtual DbExpression VisitExpression(DbExpression expression) { DbExpression newValue = null; if (expression != null) { newValue = expression.Accept<DbExpression>(this); } return newValue; }
0
7. Example
View licensestatic 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); }
0
8. Example
View licensestatic internal PropagatorResult Evaluate(DbExpression node, PropagatorResult row, Propagator parent) { DbExpressionVisitor<PropagatorResult> evaluator = new Evaluator(row, parent); return node.Accept(evaluator); }
0
9. Example
View licenseinternal DbExpressionEntitySetInfo VisitExpression(DbExpression expression) { return expression.Accept(this); }
0
10. Example
View licenseprivate Node VisitExpr(DbExpression e) { if (e == null) { return null; } else { return e.Accept<Node>(this); } }
0
11. Example
View licenseinternal 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(); }
0
12. Example
View licensepublic override void Visit(DbIsNullExpression expression) { expression.Argument.Accept(this); _commandText.Append(" is null"); }
0
13. Example
View licensepublic 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); } }
0
14. Example
View licenseprivate void VisitBinary(DbBinaryExpression expression, string separator) { _commandText.Append("("); expression.Left.Accept(this); _commandText.Append(separator); expression.Right.Accept(this); _commandText.Append(")"); }
0
15. Example
View licenseinternal static bool NeedsRewrite(DbExpression expr) { Sql8ConformanceChecker checker = new Sql8ConformanceChecker(); return expr.Accept(checker); }
0
16. Example
View licenseprivate bool VisitExpression(DbExpression expression) { if (expression == null) { return false; } return expression.Accept(this); }
0
17. Example
View licensepublic 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(); }
0
18. Example
View licensepublic override SqlFragment Visit(DbIsEmptyExpression expression) { ExistsFragment f = new ExistsFragment(expression.Argument.Accept(this)); f.Negate(); return f; }
0
19. Example
View licensepublic override SqlFragment Visit(DbCastExpression expression) { //TODO: handle casting return expression.Argument.Accept(this); }
0
20. Example
View licensepublic override SqlFragment Visit(DbLikeExpression expression) { LikeFragment f = new LikeFragment(); f.Argument = expression.Argument.Accept(this); f.Pattern = expression.Pattern.Accept(this); return f; }
0
21. Example
View licensepublic override SqlFragment Visit(DbIsNullExpression expression) { IsNullFragment f = new IsNullFragment(); f.Argument = expression.Argument.Accept(this); return f; }
0
22. Example
View licenseprotected 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; }
0
23. Example
View licenseprivate void VisitBinding(DbExpressionBinding binding) { _key.Append("BV"); VisitVariableName(binding.VariableName); _key.Append("=("); binding.Expression.Accept(this); _key.Append(')'); }
0
24. Example
View licenseprivate void VisitGroupBinding(DbGroupExpressionBinding groupBinding) { _key.Append("GBVV"); VisitVariableName(groupBinding.VariableName); _key.Append(","); VisitVariableName(groupBinding.GroupVariableName); _key.Append("=("); groupBinding.Expression.Accept(this); _key.Append(')'); }
0
25. Example
View licenseprivate void VisitUnary(DbUnaryExpression expr) { VisitExprKind(expr.ExpressionKind); _key.Append('('); expr.Argument.Accept(this); _key.Append(')'); }
0
26. Example
View licenseprivate void VisitBinary(DbBinaryExpression expr) { VisitExprKind(expr.ExpressionKind); _key.Append('('); expr.Left.Accept(this); _key.Append(','); expr.Right.Accept(this); _key.Append(')'); }
0
27. Example
View licenseprivate void VisitCastOrTreat(DbUnaryExpression e) { VisitExprKind(e.ExpressionKind); _key.Append('('); e.Argument.Accept(this); _key.Append(":"); _key.Append(e.ResultType.Identity); _key.Append(')'); }
0
28. Example
View licensepublic 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(")"); }
0
29. Example
View licensepublic override void Visit(DbPropertyExpression e) { e.Instance.Accept(this); VisitExprKind(e.ExpressionKind); _key.Append(e.Property.Name); }
0
30. Example
View licensepublic 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(')'); }
0
31. Example
View licensepublic 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(')'); }
0
32. Example
View licensepublic override void Visit(DbIsOfExpression e) { VisitExprKind(e.ExpressionKind); _key.Append('('); e.Argument.Accept(this); _key.Append(":"); _key.Append(e.OfType.EdmType.Identity); _key.Append(')'); }
0
33. Example
View licensepublic override void Visit(DbOfTypeExpression e) { VisitExprKind(e.ExpressionKind); _key.Append('('); e.Argument.Accept(this); _key.Append(":"); _key.Append(e.OfType.EdmType.Identity); _key.Append(')'); }
0
34. Example
View licensepublic 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("))"); }
0
35. Example
View licensepublic 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(')'); }
0
36. Example
View licensepublic 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("))"); }
0
37. Example
View licenseinternal 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; }
0
38. Example
View licensepublic override TReturn Visit(DbExpression expression) { if (null != expression) { return expression.Accept(this); } else { throw ConstructNotSupportedException(expression); } }
0
39. Example
View licenseinternal static string GenerateUpdateSql(DbUpdateCommandTree tree, SqlVersion sqlVersion, out List&l/n ..... /n //View Source file for more details /n }
0
40. Example
View licenseprivate 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(")"); }
0
41. Example
View licenseprivate static void AppendConvertToVarchar(SqlGenerator sqlgen, SqlBuilder result, DbExpression e) { result.Append("convert(varchar(255), "); result.Append(e.Accept(sqlgen)); result.Append(")"); }
0
42. Example
View licenseprivate 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; }
0
43. Example
View licenseprivate 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; }
0
44. Example
View licenseprivate SqlSelectStatement VisitInputExpression(DbExpression inputExpression, string inp/n ..... /n //View Source file for more details /n }
0
45. Example
View licenseprivate 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; }
0
46. Example
View licenseprivate 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; }
0
47. Example
View licenseprivate 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); }
0
48. Example
View licenseprivate 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; }
0
49. Example
View licensepublic 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(); }
0
50. Example
View licenseprivate 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; }