internal override SqlNode Visit(SqlNode node) { SqlExpression expr = node as SqlExpression; if (expr != null) { bool isBlocked = this.isBlocked; this.isBlocked = false; if (CanRecurseColumnize(expr)) { base.Visit(expr); } if (!this.isBlocked) { if (!IsClientOnly(expr) && (expr.NodeType != SqlNodeType.Column) && expr.SqlType.CanBeColumn && (this.fnCanBeColumn == null || this.fnCanBeColumn(expr))) { this.candidates.Add(expr); } else { this.isBlocked = true; } } this.isBlocked |= isBlocked; } return(node); }
private List <SqlParameterInfo> ParameterizeInternal(SqlNode node) { var visitor = new Visitor(this); visitor.Visit(node); return(new List <SqlParameterInfo>(visitor.currentParams)); }
// Methods internal static Dictionary <SqlAlias, bool> Gather(SqlNode node) { Gatherer gatherer = new Gatherer(); gatherer.Visit(node); return(gatherer.Produced); }
// Methods internal SqlUnion(SqlNode left, SqlNode right, bool all) : base(SqlNodeType.Union, right.SourceExpression) { this.Left = left; this.Right = right; this.All = all; }
internal List <SqlNodeAnnotation> Get(SqlNode node) { List <SqlNodeAnnotation> list = null; this.annotationMap.TryGetValue(node, out list); return(list); }
internal void Validate(SqlNode node) { foreach (SqlVisitor visitor in validators) { visitor.Visit(node); } }
internal override SqlExpression VisitAliasRef(SqlAliasRef aref) { SqlNode node = aref.Alias.Node; if ((node is SqlTable) || (node is SqlTableValuedFunctionCall)) { return(aref); } SqlUnion union = node as SqlUnion; if (union != null) { return(this.ExpandUnion(union)); } SqlSelect select = node as SqlSelect; if (select != null) { return(this.VisitExpression(select.Selection)); } SqlExpression exp = node as SqlExpression; if (exp == null) { throw Error.CouldNotHandleAliasRef(node.NodeType); } return(this.VisitExpression(exp)); }
private void GatherUnionExpressions(SqlNode node, IList <SqlExpression> exprs) { SqlUnion union = node as SqlUnion; if (union != null) { this.GatherUnionExpressions(union.Left, exprs); this.GatherUnionExpressions(union.Right, exprs); } else { SqlSelect select = node as SqlSelect; if (select != null) { SqlAliasRef selection = select.Selection as SqlAliasRef; if (selection != null) { this.GatherUnionExpressions(selection.Alias.Node, exprs); } else { exprs.Add(select.Selection); } } } }
// Methods internal static SqlNode Reduce(SqlNode node, SqlNodeAnnotations annotations) { Reducer reducer = new Reducer(); reducer.Annotations = annotations; return(reducer.Visit(node)); }
private static IProviderType GetSqlType(SqlNode node) { SqlExpression expression = node as SqlExpression; if (expression != null) { return(expression.SqlType); } SqlSelect select = node as SqlSelect; if (select != null) { return(select.Selection.SqlType); } SqlTable table = node as SqlTable; if (table != null) { return(table.SqlRowType); } SqlUnion union = node as SqlUnion; if (union == null) { throw Error.UnexpectedNode(node.NodeType); } return(union.GetSqlType()); }
// Methods internal static bool ReferencesAny(SqlNode node, IEnumerable <SqlAlias> aliases) { Visitor visitor = new Visitor(); visitor.aliases = aliases; visitor.Visit(node); return(visitor.referencesAnyMatchingAliases); }
// Fields // Methods internal QueryInfo(SqlNode query, string commandText, ReadOnlyCollection <SqlParameterInfo> parameters, SqlProvider.ResultShape resultShape, Type resultType) { this.Query = query; this.CommandText = commandText; this.Parameters = parameters; this.ResultShape = resultShape; this.ResultType = resultType; }
// Methods internal static bool IsDependent(SqlNode node, Dictionary <SqlAlias, bool> aliasesToCheck, Dictionary <SqlExpression, bool> ignoreExpressions) { Visitor visitor = new Visitor(aliasesToCheck, ignoreExpressions); visitor.Visit(node); return(visitor.hasDependency); }
internal bool NodeIsAnnotated(SqlNode node) { if (node == null) { return(false); } return(this.annotationMap.ContainsKey(node)); }
internal override SqlNode Visit(SqlNode node) { if (this.IsValid && (node != null)) { return(base.Visit(node)); } return(node); }
// Methods internal override SqlNode Visit(SqlNode node) { if (this.referencesAnyMatchingAliases) { return(node); } return(base.Visit(node)); }
internal override SqlNode Visit(SqlNode node) { node = base.Visit(node); if (node != null) { node.ClearSourceExpression(); } return(node); }
internal SqlNode Deflate(SqlNode node) { node = this.vDeflator.Visit(node); node = this.cDeflator.Visit(node); node = this.aDeflator.Visit(node); node = this.tsDeflator.Visit(node); node = this.dupColumnDeflator.Visit(node); return(node); }
internal override SqlNode VisitUnion(SqlUnion su) { Scope current = this.current; this.current = null; SqlNode node = base.VisitUnion(su); this.current = current; return(node); }
private void Validate(SqlNode node) { if (node == null) { throw Error.ArgumentNull("node"); } if ((!(node is SqlExpression) && !(node is SqlSelect)) && !(node is SqlUnion)) { throw Error.UnexpectedNode(node.NodeType); } }
// Methods internal void Add(SqlNode node, SqlNodeAnnotation annotation) { List <SqlNodeAnnotation> list = null; if (!this.annotationMap.TryGetValue(node, out list)) { list = new List <SqlNodeAnnotation>(); this.annotationMap[node] = list; } this.uniqueTypes[annotation.GetType()] = string.Empty; list.Add(annotation); }
internal override SqlNode Visit(SqlNode node) { SqlExpression key = node as SqlExpression; if (this.hasDependency) { return(node); } if ((key != null) && this.ignoreExpressions.ContainsKey(key)) { return(node); } return(base.Visit(node)); }
internal override SqlNode Visit(SqlNode node) { SqlExpression item = node as SqlExpression; if ((item == null) || !this.candidates.Contains(item)) { return(base.Visit(node)); } if ((item.NodeType != SqlNodeType.Column) && (item.NodeType != SqlNodeType.ColumnRef)) { return(new SqlColumn(item.ClrType, item.SqlType, null, null, item, item.SourceExpression)); } return(item); }
// Methods internal static void ThrowIfUnsupported(SqlNode node, SqlNodeAnnotations annotations, SqlProvider.ProviderMode provider) { if (annotations.HasAnnotationType(typeof(SqlServerCompatibilityAnnotation))) { Visitor visitor = new Visitor(provider); visitor.annotations = annotations; visitor.Visit(node); if (visitor.reasons.Count > 0) { throw Error.ExpressionNotSupportedForSqlServerVersion(visitor.reasons); } } }
internal override SqlNode Visit(SqlNode node) { if (node == null) { return(null); } SqlNode node2 = null; if (!this.nodeMap.TryGetValue(node, out node2)) { node2 = base.Visit(node); this.nodeMap[node] = node2; } return(node2); }
internal override SqlNode Visit(SqlNode node) { if (annotations.NodeIsAnnotated(node)) { foreach (SqlNodeAnnotation annotation in annotations.Get(node)) { SqlServerCompatibilityAnnotation annotation2 = annotation as SqlServerCompatibilityAnnotation; if ((annotation2 != null) && annotation2.AppliesTo(provider)) { reasons.Add(annotation.Message); } } } return(base.Visit(node)); }
// Methods internal static bool CanConvert(SqlNode node) { var bo = node as SqlBinary; if ((bo == null) || (!IsCompareToValue(bo) && !IsVbCompareStringEqualsValue(bo))) { var m = node as SqlMember; if ((m == null) || !IsSupportedMember(m)) { var mc = node as SqlMethodCall; if ((mc == null) || (!IsSupportedMethod(mc) && !IsSupportedVbHelperMethod(mc))) { return(false); } } } return(true); }
ReadOnlyCollection <ReadOnlyCollection <SqlParameterInfo> > ISqlParameterizer.ParameterizeBlock(SqlBlock block) { var item = new SqlParameterInfo(new SqlParameter(typeof(int), typeProvider.From(typeof(int)), "@ROWCOUNT", block.SourceExpression)); var list = new List <ReadOnlyCollection <SqlParameterInfo> >(); int num = 0; int count = block.Statements.Count; while (num < count) { SqlNode node = block.Statements[num]; List <SqlParameterInfo> list2 = this.ParameterizeInternal(node); if (num > 0) { list2.Add(item); } list.Add(list2.AsReadOnly()); num++; } return(list.AsReadOnly()); }
private static Type GetClrType(SqlNode node) { SqlTableValuedFunctionCall call = node as SqlTableValuedFunctionCall; if (call != null) { return(call.RowType.Type); } SqlExpression expression = node as SqlExpression; if (expression != null) { if (TypeSystem.IsSequenceType(expression.ClrType)) { return(TypeSystem.GetElementType(expression.ClrType)); } return(expression.ClrType); } SqlSelect select = node as SqlSelect; if (select != null) { return(select.Selection.ClrType); } SqlTable table = node as SqlTable; if (table != null) { return(table.RowType.Type); } SqlUnion union = node as SqlUnion; if (union == null) { throw Error.UnexpectedNode(node.NodeType); } return(union.GetClrType()); }
internal static SqlNode Copy(SqlNode node) { if (node == null) { return(null); } SqlNodeType nodeType = node.NodeType; if (nodeType != SqlNodeType.ColumnRef) { switch (nodeType) { case SqlNodeType.Variable: case SqlNodeType.Value: return(node); case SqlNodeType.Parameter: return(node); } return(new SqlDuplicator().Duplicate(node)); } return(node); }