• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SelectStatement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: RenderSingleQuery

        private static void RenderSingleQuery(SelectStatement select, DbmsType dbms, StringBuilder output, DbParameterCollection parameters)
        {
            // Either TOP or ORDER BY is used; but not both.

            // SELECT ... FROM ...
            // WHERE (ROWNUM <= @top) AND (@this.filter)
            // GROUP BY ... HAVING ... ORDER BY ...
            AppendSelectAndDistinctKeyWords(select, output);
            AppendSelectList(select, dbms, output, parameters);
            AppendFromClause(select, dbms, output);

            // WHERE. We have made sure that if TOP is used then ORDER BY is not used.
            if (select.Top > 0)
            {
                // WHERE ROWNUM <= this.top AND (this.filter).
                output.Append(" WHERE ROWNUM <= " + select.Top.ToString(CultureInfo.InvariantCulture));

                if (select.Where != null && !select.Where.IsEmpty)
                {
                    output.Append(" AND (");
                    select.Where.Render(dbms, output, parameters);
                    output.Append(")");
                }
            }
            else
            {
                AppenWhereWoRownum(select, dbms, output, parameters);
            }

            AppendGroupByClause(select, dbms, output, parameters);
            AppendHavingClause(select, dbms, output, parameters);
            AppendOrderByClause(select, dbms, output, parameters);
        }        
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:33,代码来源:OracleSelectRenderer.cs


示例2: CreateSelectFromLevelQuery

        private static SelectStatement CreateSelectFromLevelQuery(IEntity rootEntity, DbRelation recursiveRelation, SearchCondition leafFilter, int level, LevelQuerySelectList itemsToSelect)
        {
            if (level > Settings.GenericHierarchicalQueryExecutorMaxLevel)
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, Messages.GenericHierarchicalQueryExecutor_MaxLevelReachedFormat, Settings.GenericHierarchicalQueryExecutorMaxLevel));

            // Target level table must be child table because that is the table which is used in leafFilter.
            // If leaf filter is used then the we must ensure that proper table name is used for target table.
            IDbTable targetLevelTable;
            if (leafFilter != null && !leafFilter.IsEmpty)
                targetLevelTable = recursiveRelation.Child;
            else
                targetLevelTable = rootEntity.Table.Clone("L" + level);

            SelectStatement selectFromTargetLevel = new SelectStatement(targetLevelTable);
            CreateSelectListItems(itemsToSelect, targetLevelTable, selectFromTargetLevel);

            if (leafFilter != null && !leafFilter.IsEmpty)
                selectFromTargetLevel.Where.Add(leafFilter);

            IDbTable prevLevel = targetLevelTable;
            for (int parentLevel = level - 1; parentLevel >= 0; parentLevel--)
            {
                IDbTable nextLevel = rootEntity.Table.Clone("L" + parentLevel);
                DbRelation joinLevels = JoinLevelsInSubTree(prevLevel, nextLevel, recursiveRelation);
                selectFromTargetLevel.Relations.Add(joinLevels, false, false);
                prevLevel = nextLevel;
            }

            IDbTable subTreeRoot = prevLevel;
            foreach (IDbColumn rootPkPart in subTreeRoot.PrimaryKey)
                selectFromTargetLevel.Where.Add(rootPkPart, rootEntity.GetField(rootPkPart));

            return selectFromTargetLevel;
        }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:34,代码来源:GenericHierarchicalQueryExecutor.cs


示例3: ApplyCondition

        public SelectStatement ApplyCondition(SelectStatement statement)
        {
            var extractor = new CriteriaOperatorExtractor();
            extractor.Extract(statement.Condition);
            traceStatement(statement, "ApplyCondition");

            foreach (FilterProviderBase provider in FilterProviderManager.Providers)
            {
                FilterProviderBase providerBase = FilterProviderManager.GetFilterProvider(provider.FilterMemberName);
                if (providerBase!= null)
                {
                    Tracing.Tracer.LogVerboseValue("providerName", providerBase.Name);
                    IEnumerable<BinaryOperator> binaryOperators =
                        extractor.BinaryOperators.Where(
                            @operator =>
                            @operator.RightOperand is OperandValue &&
                            ReferenceEquals(((OperandValue) @operator.RightOperand).Value, providerBase.FilterMemberName));
                    if (!FilterIsShared(statement.TableName,providerBase.Name) && binaryOperators.Count() == 0&&!IsSystemTable(statement.TableName))
                    {
                        string s = providerBase.FilterValue== null? null:providerBase.FilterValue.ToString();

                        string nodeAlias = statement.Operands.OfType<QueryOperand>().Where(
                                               operand => operand.ColumnName == providerBase.FilterMemberName).Select(
                                               operand => operand.NodeAlias).FirstOrDefault() ?? statement.Alias;
                        statement.Condition &= new QueryOperand(providerBase.FilterMemberName, nodeAlias) ==s;
                        Tracing.Tracer.LogVerboseValue("new_statement", statement);
                    }
                }
            }
            return statement;
        }
开发者ID:cevious,项目名称:eXpand,代码行数:31,代码来源:FilterDataStoreModule.cs


示例4: AppendSelectAndDistinctKeyWords

 private static void AppendSelectAndDistinctKeyWords(SelectStatement select, StringBuilder output)
 {
     // SELECT.
     output.Append("SELECT ");
     if (select.Distinct)
         output.Append("DISTINCT ");
 }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:7,代码来源:SqlServerSelectRenderer.cs


示例5: Visit

		public void Visit(SelectStatement select_statement)
		{
			_Query.Append("SELECT ");

			if (select_statement.IsDistinct)
				_Query.Append("DISTINCT ");

			if (select_statement.SelectedAllColumns)
				_Query.Append("* ");

			if (select_statement.SelectedAllColumns && select_statement.SelectList.Count != 0)
				_Query.Append(", ");

			foreach(ISQLExpression item in select_statement.SelectList)
			{
				item.Accept(this);
				if ( select_statement.SelectList.IndexOf(item) != select_statement.SelectList.Count - 1 )
					_Query.Append(", ");
			}

            select_statement.FromClause.Accept(this);
			
			if (select_statement.WhereClause != null)
				select_statement.WhereClause.Accept(this);
			
			if( select_statement.OrderByClause != null)
				select_statement.OrderByClause.Accept(this);
		}
开发者ID:npenin,项目名称:uss,代码行数:28,代码来源:BaseStringSQLVisitor.cs


示例6: NotExists

        public static Predicate NotExists(SelectStatement subQuery)
        {
            if (subQuery == null) {
                throw new ArgumentNullException("subQuery");
            }

            return new NotExistsPredicate(subQuery);
        }
开发者ID:codeinsiders,项目名称:sharpql,代码行数:8,代码来源:Predicate.cs


示例7: AppendSelectList

 private static void AppendSelectList(SelectStatement select, DbmsType dbms, StringBuilder output, DbParameterCollection parameters)
 {
     // Select list.
     if (select.SelectList != null && select.SelectList.Count > 0)
         select.SelectList.Render(dbms, output, parameters);
     else
         output.Append("*");
 }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:8,代码来源:SqlServerSelectRenderer.cs


示例8: ProcessOptimizerHints

 private void ProcessOptimizerHints(IList<OptimizerHint> OptimizerHints, SelectStatement SelStatement)
 {
     /* OptimizerHints is not a decendant of TSQLFragment */
     foreach (OptimizerHint Hint in OptimizerHints)
     {
         ProcessHint(Hint, SelStatement);
     }
 }
开发者ID:dalehhirt,项目名称:TSQL-Smells,代码行数:8,代码来源:SelectStatementProcessor.cs


示例9: SubQuery

    public SubQuery(SelectStatement select) {
      mySelect = select.Clone();
      Name = Naming.NewTableName();

      foreach (Expression column in mySelect.Columns) {
        column.VisitAll<BindExpression>(x => x.BindColumn.Table = this);
      }
    }
开发者ID:slewrate,项目名称:csharpsqlbuilder,代码行数:8,代码来源:SubQuery.cs


示例10: ExistsPredicate

        internal ExistsPredicate(SelectStatement subQuery)
        {
            if (subQuery == null) {
                throw new ArgumentNullException("subQuery");
            }

            this.SubQuery = subQuery;
        }
开发者ID:codeinsiders,项目名称:sharpql,代码行数:8,代码来源:ExistsPredicate.cs


示例11: AppendGroupByClause

 private static void AppendGroupByClause(SelectStatement select, DbmsType dbms, StringBuilder output, DbParameterCollection parameters)
 {
     // GROUP BY.
     if (select.GroupBy != null && select.GroupBy.Fields.Count > 0)
     {
         output.Append(" ");
         select.GroupBy.Render(dbms, output, parameters);
     }
 }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:9,代码来源:GenericSelectRenderer.cs


示例12: CreateSelectListItems

 private static void CreateSelectListItems(LevelQuerySelectList itemsToSelect, IDbTable targetLevelTable, SelectStatement selectFromTargetLevel)
 {
     if (itemsToSelect == LevelQuerySelectList.AllColumns)
         selectFromTargetLevel.SelectList.Add(targetLevelTable.Columns);
     else if (itemsToSelect == LevelQuerySelectList.Count)
         selectFromTargetLevel.SelectList.Add(AggregateFunctionFactory.Count("nodeCount"));
     else if (itemsToSelect == LevelQuerySelectList.PrimaryKey)
         selectFromTargetLevel.SelectList.Add(targetLevelTable.PrimaryKey);
 }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:9,代码来源:GenericHierarchicalQueryExecutor.cs


示例13: AppendWhereClause

 private static void AppendWhereClause(SelectStatement select, DbmsType dbms, StringBuilder output, DbParameterCollection parameters)
 {
     // WHERE.
     if (select.Where != null && !select.Where.IsEmpty)
     {
         output.Append(" WHERE ");
         select.Where.Render(dbms, output, parameters);
     }
 }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:9,代码来源:SqlServerSelectRenderer.cs


示例14: AppendHavingClause

 private static void AppendHavingClause(SelectStatement select, DbmsType dbms, StringBuilder output, DbParameterCollection parameters)
 {
     // HAVING.
     if (select.Having != null && !select.Having.IsEmpty)
     {
         output.Append(" HAVING ");
         select.Having.Render(dbms, output, parameters);
     }
 }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:9,代码来源:GenericSelectRenderer.cs


示例15: Render

 public void Render(SelectStatement select, DbmsType dbms, StringBuilder output, DbParameterCollection parameters)
 {
     // Uses ROWNUM instead of TOP. If ORDER BY is used then current SELECT statement is rendered
     // using sub-queries. ROWNUM is used in outer query.
     bool orderByIsUsed = (select.OrderBy != null && select.OrderBy.Count > 0);
     if (select.Top > 0 && orderByIsUsed)
         RenderOrderByInSubQueryAndRownumInOuterQuery(select, dbms, output, parameters);
     else
         RenderSingleQuery(select, dbms, output, parameters);
 }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:10,代码来源:OracleSelectRenderer.cs


示例16: AppendTopExpression

 private static void AppendTopExpression(SelectStatement select, StringBuilder output)
 {
     // TOP - only SQL Server.
     if (select.Top > 0)
     {
         output.Append("TOP ");
         output.Append(select.Top.ToString(CultureInfo.InvariantCulture));
         output.Append(" ");
     }
 }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:10,代码来源:SqlServerSelectRenderer.cs


示例17: Process

 public void Process(SelectStatement SelStatement, string ParentType, bool TestTop = false,
     WithCtesAndXmlNamespaces Cte = null)
 {
     if (Cte == null && SelStatement.WithCtesAndXmlNamespaces != null)
     {
         Cte = SelStatement.WithCtesAndXmlNamespaces;
         if (Cte != null) _smells.InsertProcessor.ProcessWithCtesAndXmlNamespaces(Cte);
     }
     _smells.ProcessQueryExpression(SelStatement.QueryExpression, ParentType, false, Cte);
     ProcessOptimizerHints(SelStatement.OptimizerHints, SelStatement);
 }
开发者ID:dalehhirt,项目名称:TSQL-Smells,代码行数:11,代码来源:SelectStatementProcessor.cs


示例18: Render

 public void Render(SelectStatement select, DbmsType dbms, StringBuilder output, DbParameterCollection parameters)
 {
     AppendSelectAndDistinctKeyWords(select, output);
     AppendTopExpression(select, output);
     AppendSelectList(select, dbms, output, parameters);
     AppendFromClause(select, dbms, output);
     AppendWhereClause(select, dbms, output, parameters);
     AppendGroupByClause(select, dbms, output, parameters);
     AppendHavingClause(select, dbms, output, parameters);
     AppendOrderByClause(select, dbms, output, parameters);
 }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:11,代码来源:SqlServerSelectRenderer.cs


示例19: GetCallingCode

        private string GetCallingCode(CreateFunctionStatement function)
        {
            var callingSelect = new SelectStatement();
            var spec = (callingSelect.QueryExpression = new QuerySpecification()) as QuerySpecification;
            spec.FromClause = new FromClause();
            spec.FromClause.TableReferences.Add(new SchemaObjectFunctionTableReference()
            {
                SchemaObject = function.Name
            });

            spec.SelectElements.Add(new SelectStarExpression());

            return ScriptDom.GenerateTSql(spec);
        }
开发者ID:japj,项目名称:SSDT-DevPack,代码行数:14,代码来源:CodeExtractor.cs


示例20: Build

        public IEnumerable<SqlStatement> Build()
        {
            if (queryExpression == null)
                throw new InvalidOperationException("The query expression is required");

            var statement = new SelectStatement(queryExpression);

            if (sortColumns.Count > 0)
                statement.OrderBy = sortColumns.AsReadOnly();

            if (queryLimit != null)
                statement.Limit = queryLimit;

            return new[] {statement};
        }
开发者ID:deveel,项目名称:deveeldb,代码行数:15,代码来源:SelectStatementBuilder.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SelectedItem类代码示例发布时间:2022-05-24
下一篇:
C# SelectQuery类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap