예제 #1
0
            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);
            }
예제 #2
0
        private List <SqlParameterInfo> ParameterizeInternal(SqlNode node)
        {
            var visitor = new Visitor(this);

            visitor.Visit(node);
            return(new List <SqlParameterInfo>(visitor.currentParams));
        }
예제 #3
0
        // Methods
        internal static Dictionary <SqlAlias, bool> Gather(SqlNode node)
        {
            Gatherer gatherer = new Gatherer();

            gatherer.Visit(node);
            return(gatherer.Produced);
        }
예제 #4
0
파일: SqlUnion.cs 프로젝트: zyj0021/ALinq
 // Methods
 internal SqlUnion(SqlNode left, SqlNode right, bool all)
     : base(SqlNodeType.Union, right.SourceExpression)
 {
     this.Left  = left;
     this.Right = right;
     this.All   = all;
 }
예제 #5
0
        internal List <SqlNodeAnnotation> Get(SqlNode node)
        {
            List <SqlNodeAnnotation> list = null;

            this.annotationMap.TryGetValue(node, out list);
            return(list);
        }
예제 #6
0
 internal void Validate(SqlNode node)
 {
     foreach (SqlVisitor visitor in validators)
     {
         visitor.Visit(node);
     }
 }
예제 #7
0
            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));
            }
예제 #8
0
            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);
                        }
                    }
                }
            }
예제 #9
0
        // Methods
        internal static SqlNode Reduce(SqlNode node, SqlNodeAnnotations annotations)
        {
            Reducer reducer = new Reducer();

            reducer.Annotations = annotations;
            return(reducer.Visit(node));
        }
예제 #10
0
        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());
        }
예제 #11
0
        // Methods
        internal static bool ReferencesAny(SqlNode node, IEnumerable <SqlAlias> aliases)
        {
            Visitor visitor = new Visitor();

            visitor.aliases = aliases;
            visitor.Visit(node);
            return(visitor.referencesAnyMatchingAliases);
        }
예제 #12
0
            // 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;
            }
예제 #13
0
            // 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);
            }
예제 #14
0
 internal bool NodeIsAnnotated(SqlNode node)
 {
     if (node == null)
     {
         return(false);
     }
     return(this.annotationMap.ContainsKey(node));
 }
예제 #15
0
 internal override SqlNode Visit(SqlNode node)
 {
     if (this.IsValid && (node != null))
     {
         return(base.Visit(node));
     }
     return(node);
 }
예제 #16
0
 // Methods
 internal override SqlNode Visit(SqlNode node)
 {
     if (this.referencesAnyMatchingAliases)
     {
         return(node);
     }
     return(base.Visit(node));
 }
예제 #17
0
 internal override SqlNode Visit(SqlNode node)
 {
     node = base.Visit(node);
     if (node != null)
     {
         node.ClearSourceExpression();
     }
     return(node);
 }
예제 #18
0
 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);
 }
예제 #19
0
            internal override SqlNode VisitUnion(SqlUnion su)
            {
                Scope current = this.current;

                this.current = null;
                SqlNode node = base.VisitUnion(su);

                this.current = current;
                return(node);
            }
예제 #20
0
파일: SqlUnion.cs 프로젝트: zyj0021/ALinq
 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);
     }
 }
예제 #21
0
        // 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);
        }
예제 #22
0
                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));
                }
예제 #23
0
            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);
            }
예제 #24
0
 // 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);
         }
     }
 }
예제 #25
0
            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);
            }
예제 #26
0
 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));
 }
예제 #27
0
        // 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);
        }
예제 #28
0
        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());
        }
예제 #29
0
        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());
        }
예제 #30
0
        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);
        }