当前位置: 首页>>代码示例>>C#>>正文


C# SqlSelect类代码示例

本文整理汇总了C#中SqlSelect的典型用法代码示例。如果您正苦于以下问题:C# SqlSelect类的具体用法?C# SqlSelect怎么用?C# SqlSelect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SqlSelect类属于命名空间,在下文中一共展示了SqlSelect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VisitSelect

            internal override SqlSelect VisitSelect(SqlSelect select) {
                Scope save = this.current;
                this.current = new Scope(select.Where, this.current);

                SqlSelect result = base.VisitSelect(select);

                bool stopHoisting =
                    select.IsDistinct ||
                    select.GroupBy.Count > 0 ||
                    this.aggregateChecker.HasAggregates(select) ||
                    select.Top != null ||
                    this.rowNumberChecker.HasRowNumber(select);

                // Shift as much of the current WHERE to the parent as possible.
                if (this.current != null) {
                    if (this.current.Parent != null && !stopHoisting) {
                        this.current.Parent.Where = sql.AndAccumulate(this.current.Parent.Where, this.current.Where);
                        this.current.Where = null;
                    }
                    select.Where = this.current.Where;
                }

                this.current = save;
                return result;
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:25,代码来源:SqlLiftWhereClauses.cs

示例2: VisitSelect

            internal override SqlSelect VisitSelect(SqlSelect select) {
                select = base.VisitSelect(select);

                string[] names = new string[select.Row.Columns.Count];
                for (int i = 0, n = names.Length; i < n; i++) {
                    SqlColumn c = select.Row.Columns[i];
                    string name = c.Name;
                    if (name == null) {
                        name = SqlNamer.DiscoverName(c);
                    }
                    names[i] = name;
                    c.Name = null;
                }
                
                var reservedNames = this.GetColumnNames(select.OrderBy);

                for (int i = 0, n = select.Row.Columns.Count; i < n; i++) {
                    SqlColumn c = select.Row.Columns[i];
                    string rootName = names[i];
                    string name = rootName;
                    if (this.makeUnique) {
                        int iName = 1;
                        while (!this.IsUniqueName(select.Row.Columns, reservedNames, c, name)) {
                            iName++;
                            name = rootName + iName;
                        }
                    }
                    c.Name = name;
                    c.Ordinal = i;
                }

                return select;
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:33,代码来源:SqlNamer.cs

示例3: VisitMultiset

            internal override SqlExpression VisitMultiset(SqlSubSelect sms) {
                // allow one big-join per query?
                if ((this.options & Options.EnableBigJoin) != 0 &&
                    !this.hasBigJoin && this.canJoin && this.isTopLevel && this.outerSelect != null
                    && !MultisetChecker.HasMultiset(sms.Select.Selection) 
                    && BigJoinChecker.CanBigJoin(sms.Select)) {

                    sms.Select = this.VisitSelect(sms.Select);

                    SqlAlias alias = new SqlAlias(sms.Select);
                    SqlJoin join = new SqlJoin(SqlJoinType.OuterApply, this.outerSelect.From, alias, null, sms.SourceExpression);
                    this.outerSelect.From = join;
                    this.outerSelect.OrderingType = SqlOrderingType.Always;

                    // make joined expression
                    SqlExpression expr = (SqlExpression)SqlDuplicator.Copy(sms.Select.Selection);

                    // make count expression
                    SqlSelect copySelect = (SqlSelect)SqlDuplicator.Copy(sms.Select);
                    SqlAlias copyAlias = new SqlAlias(copySelect);
                    SqlSelect countSelect = new SqlSelect(sql.Unary(SqlNodeType.Count, null, sms.SourceExpression), copyAlias, sms.SourceExpression);
                    countSelect.OrderingType = SqlOrderingType.Never;
                    SqlExpression count = sql.SubSelect(SqlNodeType.ScalarSubSelect, countSelect);

                    // make joined collection
                    SqlJoinedCollection jc = new SqlJoinedCollection(sms.ClrType, sms.SqlType, expr, count, sms.SourceExpression);
                    this.hasBigJoin = true;
                    return jc;
                }
                else {
                    return QueryExtractor.Extract(sms, this.parentParameters);
                }
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:33,代码来源:SqlMultiplexer.cs

示例4: AnalyzeSelectStmt

        private void AnalyzeSelectStmt(TSelectSqlStatement pSqlstmt)
        {
            SqlSelect q = new SqlSelect();
            // where clause this query is rule Select
            if (pSqlstmt.WhereClause != null)
            {
                Console.WriteLine(pSqlstmt.WhereClauseText);
                q.WhereClause = pSqlstmt.WhereClauseText;
            }

            //column here, when column != *, indep project
            List<string> names = new List<string>();
            foreach (TLzField fld in pSqlstmt.Fields)
            {
                var lcstr ="\n\tFullname:" + fld.FieldFullname;
                lcstr = lcstr + "\n\tPrefix:" + fld.FieldPrefix;
                lcstr = lcstr + "\tColumn:" + fld.FieldName;
                lcstr = lcstr + "\talias:" + fld.FieldAlias;
                Console.WriteLine(lcstr);
                names.Add(fld.FieldName);
            }
            q.SelectClause = names;

            // join
            names = new List<string>();
            foreach (var table in pSqlstmt.JoinTables)
            {
                Console.WriteLine(table.JoinTable.TableName);
                Console.WriteLine(table.JoinItems.Count());
                names.Add(table.JoinTable.TableName);
            }
            q.SelectClause = names;

            switch (pSqlstmt.SelectSetType)
            {
                case TSelectSetType.sltNone:
                    break;
                case TSelectSetType.sltUnion:
                    // indep union rule
                    Console.WriteLine(pSqlstmt.SelectClauseText);
                    break;
                case TSelectSetType.sltUnionAll:
                    break;
                case TSelectSetType.sltMinus:
                    break;
                case TSelectSetType.sltIntersect:
                    break;
                case TSelectSetType.sltIntersectAll:
                    break;
                case TSelectSetType.sltExcept:
                    // indep negation rule
                    Console.WriteLine(pSqlstmt.FromClauseText);
                    break;
                case TSelectSetType.sltExceptAll:
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
开发者ID:GmailYan,项目名称:ProbabilisticDatabase,代码行数:59,代码来源:GeneralSQLParser.cs

示例5: VisitSelectCore

 internal override SqlSelect VisitSelectCore(SqlSelect select) {
     bool saveIsTopLevel = this.isTopLevel;
     this.isTopLevel = false;
     try {
         return base.VisitSelectCore(select);
     }
     finally {
         this.isTopLevel = saveIsTopLevel;
     }
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:10,代码来源:SqlFlattener.cs

示例6: VisitSelect

 internal override SqlSelect VisitSelect(SqlSelect select) {
     SqlSelect save = this.currentSelect;
     try {
         this.currentSelect = select;
         return base.VisitSelect(select);
     }
     finally {
         this.currentSelect = save;
     }
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:10,代码来源:SqlRewriteScalarSubqueries.cs

示例7: ConvertColumnsToMax

 private void ConvertColumnsToMax(SqlSelect select, out bool changed, out bool containsLongExpressions) {
     SqlRow row = select.Row;
     changed = false;
     containsLongExpressions = false;
     foreach (SqlColumn col in row.Columns) {
         bool columnChanged;
         containsLongExpressions = containsLongExpressions || col.SqlType.IsLargeType;
         col.Expression = ConvertToMax(col.Expression, out columnChanged);
         changed = changed || columnChanged;     
     }
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:11,代码来源:LongTypeConverter.cs

示例8: VisitSelect

            internal override SqlSelect VisitSelect(SqlSelect select) {
                if (select.IsDistinct) {
                    bool changed;
                    bool containsLongExpressions;
                    ConvertColumnsToMax(select, out changed, out containsLongExpressions);
                    if (containsLongExpressions) {
                        this.annotations.Add(select, new SqlServerCompatibilityAnnotation(
                                             Strings.TextNTextAndImageCannotOccurInDistinct(select.SourceExpression), SqlProvider.ProviderMode.Sql2000, SqlProvider.ProviderMode.SqlCE));
                    }

                }
                return base.VisitSelect(select);
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:13,代码来源:LongTypeConverter.cs

示例9: VisitSelect

            internal override SqlSelect VisitSelect(SqlSelect select) {
                // DevDiv 179191
                if (select.Where != null && select.Where.NodeType == SqlNodeType.Coalesce) {
                    SqlBinary bin = (SqlBinary)select.Where;
                    if (bin.Right.NodeType == SqlNodeType.Value) {
                        SqlValue value = (SqlValue)bin.Right;
                        if (value.Value != null && value.Value.GetType() == typeof(bool) && (bool)value.Value == false) {
                            select.Where = bin.Left;
                        }
                    }
                }

                return base.VisitSelect(select);
            }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:14,代码来源:SqlBooleanizer.cs

示例10: VisitSelect

 internal override SqlSelect VisitSelect(SqlSelect select) {
     base.VisitSelect(select);
     if (select.Top != null) {
         if (select.Top.NodeType == SqlNodeType.Value) {
             SqlValue val = (SqlValue)select.Top;
             // convert to literal value for SQL2K compatibility
             if (val.IsClientSpecified) {
                 select.Top = sql.Value(val.ClrType, val.SqlType, val.Value, false, val.SourceExpression);
             }
         }
         else {
             // cannot be converted to literal value. note that this select is not SQL2K compatible
             this.annotations.Add(select.Top, new SqlServerCompatibilityAnnotation(Strings.SourceExpressionAnnotation(select.Top.SourceExpression), SqlProvider.ProviderMode.Sql2000));
         }
     }
     return select;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:17,代码来源:SqlTopReducer.cs

示例11: VisitSelect

        internal override SqlSelect VisitSelect(SqlSelect select) {
            select.From = this.VisitSource(select.From);
            select.Where = this.VisitPredicate(select.Where);
            for (int i = 0, n = select.GroupBy.Count; i < n; i++) {
                select.GroupBy[i] = this.VisitExpression(select.GroupBy[i]);
            }
            select.Having = this.VisitPredicate(select.Having);
            for (int i = 0, n = select.OrderBy.Count; i < n; i++) {
                select.OrderBy[i].Expression = this.VisitExpression(select.OrderBy[i].Expression);
            }
            select.Top = this.VisitExpression(select.Top);
            select.Row = (SqlRow)this.Visit(select.Row);

            // don't visit selection
            //select.Selection = this.VisitExpression(select.Selection);

            return select;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:18,代码来源:SqlBooleanMismatchVisitor.cs

示例12: VisitSelect

            internal override SqlSelect VisitSelect(SqlSelect select) {
                select = base.VisitSelect(select);

                select.Selection = this.FlattenSelection(select.Row, false, select.Selection);

                if (select.GroupBy.Count > 0) {
                    this.FlattenGroupBy(select.GroupBy);
                }

                if (select.OrderBy.Count > 0) {
                    this.FlattenOrderBy(select.OrderBy);
                }

                if (!this.isTopLevel) {
                    select.Selection = new SqlNop(select.Selection.ClrType, select.Selection.SqlType, select.SourceExpression);
                }

                return select;
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:19,代码来源:SqlFlattener.cs

示例13: VisitSelect

            internal override SqlSelect VisitSelect(SqlSelect select) {
                SelectScope s = expressionSink;
                
                // Don't lift through a TOP.
                if (select.Top != null) {
                    expressionSink = null;
                }

                // Don't lift through a GROUP BY (or implicit GROUP BY).
                if (select.GroupBy.Count > 0 || this.aggregateChecker.HasAggregates(select)) {
                    expressionSink = null;
                }

                // Don't lift through DISTINCT
                if (select.IsDistinct) {
                    expressionSink = null;
                }

                if (expressionSink != null) {
                    List<SqlColumn> keep = new List<SqlColumn>();
                    List<SqlColumn> lift = new List<SqlColumn>();

                    foreach (SqlColumn sc in select.Row.Columns) {
                        bool referencesLeftsideAliases = SqlAliasesReferenced.ReferencesAny(sc.Expression, expressionSink.LeftProduction);
                        bool isLockedExpression = expressionSink.ReferencedExpressions.Contains(sc);
                        if (referencesLeftsideAliases && !isLockedExpression) {
                            lift.Add(sc);
                        } else {
                            keep.Add(sc);
                        }
                    }
                    select.Row.Columns.Clear();
                    select.Row.Columns.AddRange(keep);
                    if (lift.Count > 0) {
                        expressionSink.Lifted.Push(lift);
                    }
                }

                SqlSelect sel = base.VisitSelect(select);
                expressionSink = s;
                return sel;
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:42,代码来源:SqlLiftIndependentRowExpressions.cs

示例14: VisitSelect

 internal override SqlSelect VisitSelect(SqlSelect select) {
     int i = 0;
     List<SqlOrderExpression> orders = select.OrderBy;
     while (i < orders.Count) {
         SqlExpression expr = orders[i].Expression;
         while (expr.NodeType == SqlNodeType.DiscriminatedType) {
             expr = ((SqlDiscriminatedType)expr).Discriminator;
         }
         switch (expr.NodeType) {
             case SqlNodeType.Value:
             case SqlNodeType.Parameter:
                 orders.RemoveAt(i);
                 break;
             default:
                 ++i;
                 break;
         }
     }
     return base.VisitSelect(select);
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:20,代码来源:SqlRemoveConstantOrderBy.cs

示例15: VisitSelect

            internal override SqlSelect  VisitSelect(SqlSelect select) {
 	            base.VisitSelect(select);

                // enforce exact ordering of columns in union selects
                SqlUnion union = this.GetUnion(select.From);
                if (union != null) {
                    SqlSelect sleft = union.Left as SqlSelect;
                    SqlSelect sright = union.Right as SqlSelect;
                    if (sleft != null & sright != null) {
                        // preset ordinals to high values (so any unreachable column definition is ordered last)
                        for (int i = 0, n = sleft.Row.Columns.Count; i < n; i++) {
                            sleft.Row.Columns[i].Ordinal = select.Row.Columns.Count + i;
                        }
                        for (int i = 0, n = sright.Row.Columns.Count; i < n; i++) {
                            sright.Row.Columns[i].Ordinal = select.Row.Columns.Count + i;
                        }
                        // next assign ordinals to all direct columns in subselects
                        for (int i = 0, n = select.Row.Columns.Count; i < n; i++) {
                            SqlExprSet es = select.Row.Columns[i].Expression as SqlExprSet;
                            if (es != null) {
                                for (int e = 0, en = es.Expressions.Count; e < en; e++) {
                                    SqlColumnRef cr = es.Expressions[e] as SqlColumnRef;
                                    if (cr != null && e >= select.Row.Columns.Count) {
                                        cr.Column.Ordinal = i;
                                    }
                                }
                            }
                        }
                        // next sort columns in left & right subselects
                        Comparison<SqlColumn> comp = (x,y) => x.Ordinal - y.Ordinal;
                        sleft.Row.Columns.Sort(comp);
                        sright.Row.Columns.Sort(comp);
                    }
                }

                return select;
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:37,代码来源:SqlUnionizer.cs


注:本文中的SqlSelect类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。