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

C# SelectExpression类代码示例

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

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



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

示例1: VisitSelect

 protected override Expression VisitSelect(SelectExpression select)
 {
     if (this.selectsToRemove.Contains(select))
         return this.Visit(select.From);
     else
         return base.VisitSelect(select);
 }
开发者ID:nuub666,项目名称:framework,代码行数:7,代码来源:SubqueryRemover.cs


示例2: VisitSelect

        protected override Expression VisitSelect(SelectExpression select)
        {
            var saveFrom = this.currentFrom;
            var saveInAggregate = this.inAggregate;

            this.inAggregate = false;

            SourceExpression from = this.VisitSource(select.From);
            this.currentFrom = from;

            Expression top = this.Visit(select.Top);
            Expression where = this.Visit(select.Where);
            ReadOnlyCollection<ColumnDeclaration> columns = select.Columns.NewIfChange(VisitColumnDeclaration);
            ReadOnlyCollection<OrderExpression> orderBy = select.OrderBy.NewIfChange(VisitOrderBy);
            ReadOnlyCollection<Expression> groupBy = select.GroupBy.NewIfChange(Visit);

            from = this.currentFrom;

            this.inAggregate = saveInAggregate;
            this.currentFrom = saveFrom;

            if (top != select.Top || from != select.From || where != select.Where || columns != select.Columns || orderBy != select.OrderBy || groupBy != select.GroupBy)
                return new SelectExpression(select.Alias, select.IsDistinct, top, columns, from, where, orderBy, groupBy, select.SelectOptions);

            return select;

        }
开发者ID:nuub666,项目名称:framework,代码行数:27,代码来源:ScalarSubqueryRewriter.cs


示例3: GetOuterJoinTest

		public static Expression GetOuterJoinTest(SelectExpression select)
		{
			// if the column is used in the join condition (equality test)
			// if it is null in the database then the join test won't match (null != null) so the row won't appear
			// we can safely use this existing column as our test to determine if the outer join produced a row

			// find a column that is used in equality test
			var aliases = DeclaredAliasGatherer.Gather(select.From);
			var joinColumns = JoinColumnGatherer.Gather(aliases, select).ToList();
			if (joinColumns.Count > 0)
			{
				// prefer one that is already in the projection list.
				foreach (var jc in joinColumns)
				{
					foreach (var col in select.Columns)
					{
						if (jc.Equals(col.Expression))
						{
							return jc;
						}
					}
				}
				return joinColumns[0];
			}

			// fall back to introducing a constant
			return Expression.Constant(1, typeof(int?));
		}
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm.Linq,代码行数:28,代码来源:QueryLanguage.cs


示例4: VisitSelect

 protected override Expression VisitSelect(SelectExpression select)
 {
     TableAlias newAlias = new TableAlias();
     this.map[select.Alias] = newAlias;
     select = (SelectExpression)base.VisitSelect(select);
     return new SelectExpression(newAlias, select.Columns, select.From, select.Where, select.OrderBy, select.GroupBy, select.IsDistinct, select.Skip, select.Take, select.IsReverse);
 }
开发者ID:jogibear9988,项目名称:IQToolkit,代码行数:7,代码来源:QueryDuplicator.cs


示例5: VisitSelect

        protected internal override Expression VisitSelect(SelectExpression select)
        {
            // visit column projection first
            HashSet<string> columnsUsed = allColumnsUsed.GetOrCreate(select.Alias); // a veces no se usa

            ReadOnlyCollection<ColumnDeclaration> columns = select.Columns.Select(c =>
            {
                if (select.IsDistinct ? IsConstant(c.Expression) : !columnsUsed.Contains(c.Name))
                    return null;

                var ex = Visit(c.Expression);

                return ex == c.Expression ? c : new ColumnDeclaration(c.Name, ex);
            }).NotNull().ToReadOnly();

            ReadOnlyCollection<OrderExpression> orderbys = Visit(select.OrderBy, VisitOrderBy);
            Expression where = this.Visit(select.Where);
            ReadOnlyCollection<Expression> groupBy = select.GroupBy.Select(e => IsConstant(e) ? null : Visit(e)).NotNull().ToReadOnly();

            SourceExpression from = this.VisitSource(select.From);

            if (columns != select.Columns || orderbys != select.OrderBy || where != select.Where || from != select.From || groupBy != select.GroupBy)
                return new SelectExpression(select.Alias, select.IsDistinct, select.Top, columns, from, where, orderbys, groupBy, select.SelectOptions);

            return select;
        }
开发者ID:rondoo,项目名称:framework,代码行数:26,代码来源:UnusedColumnRemover.cs


示例6: VisitSelect

		protected override Expression VisitSelect(SelectExpression select)
		{
			select = (SelectExpression)base.VisitSelect(select);
			if (lookup.Contains(select.Alias))
			{
				List<ColumnDeclaration> aggColumns = new List<ColumnDeclaration>(select.Columns);
				foreach (AggregateSubqueryExpression ae in lookup[select.Alias])
				{
					string name = "agg" + aggColumns.Count;
					var colType = DbTypeSystem.GetColumnType(ae.Type);
					ColumnDeclaration cd = new ColumnDeclaration(name, ae.AggregateInGroupSelect, colType);
					this.map.Add(ae, new ColumnExpression(ae.Type, colType, ae.GroupByAlias, name));
					aggColumns.Add(cd);
				}
				return new SelectExpression(
					select.Alias,
					aggColumns,
					select.From,
					select.Where,
					select.OrderBy,
					select.GroupBy,
					select.IsDistinct,
					select.Skip,
					select.Take,
					select.IsReverse);
			}
			return select;
		}
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm.Linq,代码行数:28,代码来源:AggregateRewriter.cs


示例7: VisitProjection

        protected override Expression VisitProjection(ProjectionExpression proj)
        {
            using (Scope())
            {
                var oldOuterMostSelect = outerMostSelect;
                outerMostSelect = proj.Select;

                var oldHasProjectionInProjector = hasProjectionInProjector;
                hasProjectionInProjector = false;

                Expression projector = this.Visit(proj.Projector);
                SelectExpression source = (SelectExpression)this.Visit(proj.Select);

                hasProjectionInProjector = oldHasProjectionInProjector;
                hasProjectionInProjector |= true;

                outerMostSelect = oldOuterMostSelect;
              

                if (source != proj.Select || projector != proj.Projector)
                    return new ProjectionExpression(source, projector, proj.UniqueFunction, proj.Type);

                return proj;
            }

        }
开发者ID:nuub666,项目名称:framework,代码行数:26,代码来源:OrderByRewriter.cs


示例8: VisitIn

        protected override Expression VisitIn(InExpression expression)
        {
            if (!ShouldRewrite(expression)) {
                return base.VisitIn(expression);
            }

            Array array = expression.Values.OfType<ConstantExpression>().Select(item => item.Value).Distinct().ToArray();

            var vfpDataXml = new ArrayXmlToCursor(array);
            var tableAlias = new TableAlias();
            var columnType = _language.TypeSystem.GetColumnType(vfpDataXml.ItemType);
            var columnExpression = new ColumnExpression(vfpDataXml.ItemType, columnType, tableAlias, ArrayXmlToCursor.ColumnName);

            var columns = new List<ColumnDeclaration> {
                new ColumnDeclaration(string.Empty, columnExpression, columnType)
            };

            var xml = Expression.Constant(vfpDataXml.Xml);
            var cursorName = Expression.Constant("curTemp_" + DateTime.Now.ToString("ddHHssmm"));
            var check = Expression.GreaterThan(new XmlToCursorExpression(xml, cursorName), Expression.Constant(0));
            var from = Expression.Condition(check, cursorName, Expression.Constant(string.Empty));
            var select = new SelectExpression(tableAlias, columns, from, null);

            return new InExpression(expression.Expression, select);
        }
开发者ID:,项目名称:,代码行数:25,代码来源:


示例9: VisitSelect

 protected override Expression VisitSelect(SelectExpression select)
 {
     Expression saveCurrentFrom = this.currentFrom;
     this.currentFrom = this.VisitSource(select.From);
     try
     {
         Expression where = this.Visit(select.Where);
         ReadOnlyCollection<OrderExpression> orderBy = this.VisitOrderBy(select.OrderBy);
         ReadOnlyCollection<Expression> groupBy = this.VisitExpressionList(select.GroupBy);
         Expression skip = this.Visit(select.Skip);
         Expression take = this.Visit(select.Take);
         ReadOnlyCollection<ColumnDeclaration> columns = this.VisitColumnDeclarations(select.Columns);
         if (this.currentFrom != select.From
             || where != select.Where
             || orderBy != select.OrderBy
             || groupBy != select.GroupBy
             || take != select.Take
             || skip != select.Skip
             || columns != select.Columns
             )
         {
             return new SelectExpression(select.Alias, columns, this.currentFrom, where, orderBy, groupBy, select.IsDistinct, skip, take, select.IsReverse);
         }
         return select;
     }
     finally
     {
         this.currentFrom = saveCurrentFrom;
     }
 }
开发者ID:jaykizhou,项目名称:elinq,代码行数:30,代码来源:RelationshipBinder.cs


示例10: VisitSelect

 protected override Expression VisitSelect(SelectExpression select)
 {
     if (first) {
         first = false;
         return base.VisitSelect(select);
     }
     return select;
 }
开发者ID:,项目名称:,代码行数:8,代码来源:


示例11: VisitSelect

 protected override Expression VisitSelect(SelectExpression select)
 {
     // only consider aggregates in these locations
     this.Visit(select.Where);
     this.VisitOrderBy(select.OrderBy);
     this.VisitColumnDeclarations(select.Columns);
     return select;
 }
开发者ID:bisand,项目名称:NetCouch,代码行数:8,代码来源:AggregateChecker.cs


示例12: UpdateDeclaration

 protected DeclarationCommand UpdateDeclaration(DeclarationCommand decl, IEnumerable<VariableDeclaration> variables, SelectExpression source)
 {
     if (variables != decl.Variables || source != decl.Source)
     {
         return new DeclarationCommand(variables, source);
     }
     return decl;
 }
开发者ID:bisand,项目名称:NetCouch,代码行数:8,代码来源:DbExpressionVisitor.cs


示例13: VisitSelect

        protected override Expression VisitSelect(SelectExpression select)
        {
            bool saveIsOuterMostSelect = this.isOuterMostSelect;
            try
            {
                this.isOuterMostSelect = false;
                select = (SelectExpression)base.VisitSelect(select);

                bool hasOrderBy = select.OrderBy != null && select.OrderBy.Count > 0;
                bool hasGroupBy = select.GroupBy != null && select.GroupBy.Count > 0;
                bool canHaveOrderBy = saveIsOuterMostSelect || select.Take != null || select.Skip != null;
                bool canReceiveOrderings = canHaveOrderBy && !hasGroupBy && !select.IsDistinct;

                if (hasOrderBy)
                {
                    this.PrependOrderings(select.OrderBy);
                }

                IEnumerable<OrderExpression> orderings = null;
                if (canReceiveOrderings)
                {
                    orderings = this.gatheredOrderings;
                }
                else if (canHaveOrderBy)
                {
                    orderings = select.OrderBy;
                }
                bool canPassOnOrderings = !saveIsOuterMostSelect && !hasGroupBy && !select.IsDistinct;
                ReadOnlyCollection<ColumnDeclaration> columns = select.Columns;
                if (this.gatheredOrderings != null)
                {
                    if (canPassOnOrderings)
                    {
                        var producedAliases = DeclaredAliasGatherer.Gather(select.From);
                        // reproject order expressions using this select's alias so the outer select will have properly formed expressions
                        BindResult project = this.RebindOrderings(this.gatheredOrderings, select.Alias, producedAliases, select.Columns);
                        this.gatheredOrderings = null;
                        this.PrependOrderings(project.Orderings);
                        columns = project.Columns;
                    }
                    else
                    {
                        this.gatheredOrderings = null;
                    }
                }
                if (orderings != select.OrderBy || columns != select.Columns)
                {
                    select = new SelectExpression(select.Alias, columns, select.From, select.Where, orderings, select.GroupBy, select.IsDistinct, select.Skip, select.Take);
                }
                return select;
            }
            finally
            {
                this.isOuterMostSelect = saveIsOuterMostSelect;
            }
        }
开发者ID:hamdouchi97,项目名称:Stump.ORM,代码行数:56,代码来源:OrderByRewriter.cs


示例14: AddRedundantSelect

        public static SelectExpression AddRedundantSelect(this SelectExpression sel, QueryLanguage language, TableAlias newAlias)
        {
            var newColumns =
                from d in sel.Columns
                let qt = (d.Expression is ColumnExpression) ? ((ColumnExpression)d.Expression).QueryType : language.TypeSystem.GetColumnType(d.Expression.Type)
                select new ColumnDeclaration(d.Name, new ColumnExpression(d.Expression.Type, qt, newAlias, d.Name), qt);

            var newFrom = new SelectExpression(newAlias, sel.Columns, sel.From, sel.Where, sel.OrderBy, sel.GroupBy, sel.IsDistinct, sel.Skip, sel.Take, sel.IsReverse);
            return new SelectExpression(sel.Alias, newColumns, newFrom, null, null, null, false, null, null, false);
        }
开发者ID:jogibear9988,项目名称:IQToolkit,代码行数:10,代码来源:DbExpressionExtensions.cs


示例15: IsSimpleProjection

 internal static bool IsSimpleProjection(SelectExpression select)
 {
     foreach (ColumnDeclaration decl in select.Columns) {
         ColumnExpression col = decl.Expression as ColumnExpression;
         if (col == null || decl.Name != col.Name) {
             return false;
         }
     }
     return true;
 }
开发者ID:,项目名称:,代码行数:10,代码来源:


示例16: VisitProjection

        protected override Expression VisitProjection(ProjectionExpression proj)
        {
            SelectExpression save = this.currentSelect;
            this.currentSelect = proj.Source;
            try
            {
                if (!this.isTopLevel)
                {
                    if (this.CanJoinOnClient(this.currentSelect))
                    {
                        // make a query that combines all the constraints from the outer queries into a single select
                        SelectExpression newOuterSelect = (SelectExpression)QueryDuplicator.Duplicate(save);

                        // remap any references to the outer select to the new alias;
                        SelectExpression newInnerSelect = (SelectExpression)ColumnMapper.Map(proj.Source, newOuterSelect.Alias, save.Alias);
                        // add outer-join test
                        ProjectionExpression newInnerProjection = new ProjectionExpression(newInnerSelect, proj.Projector).AddOuterJoinTest();
                        newInnerSelect = newInnerProjection.Source;
                        Expression newProjector = newInnerProjection.Projector;

                        TableAlias newAlias = new TableAlias();
                        var pc = ColumnProjector.ProjectColumns(this.language.CanBeColumn, newProjector, newOuterSelect.Columns, newAlias, newOuterSelect.Alias, newInnerSelect.Alias);
                        JoinExpression join = new JoinExpression(JoinType.OuterApply, newOuterSelect, newInnerSelect, null);
                        SelectExpression joinedSelect = new SelectExpression(newAlias, pc.Columns, join, null, null, null, proj.IsSingleton, null, null);

                        // apply client-join treatment recursively
                        this.currentSelect = joinedSelect;
                        newProjector = this.Visit(pc.Projector); 

                        // compute keys (this only works if join condition was a single column comparison)
                        List<Expression> outerKeys = new List<Expression>();
                        List<Expression> innerKeys = new List<Expression>();
                        if (this.GetEquiJoinKeyExpressions(newInnerSelect.Where, newOuterSelect.Alias, outerKeys, innerKeys))
                        {
                            // outerKey needs to refer to the outer-scope's alias
                            var outerKey = outerKeys.Select(k => ColumnMapper.Map(k, save.Alias, newOuterSelect.Alias));
                            // innerKey needs to refer to the new alias for the select with the new join
                            var innerKey = innerKeys.Select(k => ColumnMapper.Map(k, joinedSelect.Alias, ((ColumnExpression)k).Alias));
                            ProjectionExpression newProjection = new ProjectionExpression(joinedSelect, newProjector, proj.Aggregator);
                            return new ClientJoinExpression(newProjection, outerKey, innerKey);
                        }
                    }
                }
                else
                {
                    this.isTopLevel = false;
                }

                return base.VisitProjection(proj);
            }
            finally 
            {
                this.currentSelect = save;
            }
        }
开发者ID:rodrigodom,项目名称:SubSonic-3.0,代码行数:55,代码来源:ClientJoinedProjectionRewriter.cs


示例17: VisitSelect

        protected override Expression VisitSelect(SelectExpression select)
        {
            select = (SelectExpression)base.VisitSelect(select);

            // first remove all purely redundant subqueries
            List<SelectExpression> redundant = RedundantSubqueryGatherer.Gather(select.From);
            if (redundant != null)
            {
                select = SubqueryRemover.Remove(select, redundant);
            }

            return select;
        }
开发者ID:RukaiYu,项目名称:EnterpriseDevelopmentFx,代码行数:13,代码来源:RedundantSubqueryRemover.cs


示例18: AddInnerJoins

        private static SelectExpression AddInnerJoins(SelectExpression select, IEnumerable<InExpression> inExpressions)
        {
            foreach (var inExpression in inExpressions) {
                var joinExpression = new JoinExpression(JoinType.InnerJoin,
                                                        select.From,
                                                        inExpression.Select,
                                                        Expression.MakeBinary(ExpressionType.Equal, inExpression.Expression, inExpression.Select.Columns[0].Expression));

                select = select.SetFrom(joinExpression);
            }

            return select;
        }
开发者ID:,项目名称:,代码行数:13,代码来源:


示例19: VisitSelect

        protected override Expression VisitSelect(SelectExpression select)
        {
            Expression from = this.VisitSource(select.From);
            Expression where = this.Visit(select.Where);
            ReadOnlyCollection<OrderExpression> orderBy = this.VisitOrderBy(select.OrderBy);
            ReadOnlyCollection<Expression> groupBy = this.VisitExpressionList(select.GroupBy);
            Expression skip = this.Visit(select.Skip);
            Expression take = this.Visit(select.Take);
            ReadOnlyCollection<ColumnDeclaration> columns = this.VisitColumnDeclarations(select.Columns);

            SelectExpression output = new SelectExpression(select.Alias, columns, from, where, orderBy, groupBy, select.IsDistinct, skip, take);

            return output;
        }
开发者ID:Femaref,项目名称:SubSonic-3.0,代码行数:14,代码来源:NullableRewriter.cs


示例20: VisitSelect

        protected override Expression VisitSelect(SelectExpression select)
        {
            Expression top = this.Visit(select.Top);
            SourceExpression from = this.VisitSource(select.From);
            Expression where = this.Visit(select.Where);
            ReadOnlyCollection<ColumnDeclaration> columns = select.Columns.NewIfChange(VisitColumnDeclaration);
            ReadOnlyCollection<OrderExpression> orderBy = select.OrderBy.NewIfChange(VisitOrderBy);
            ReadOnlyCollection<Expression> groupBy = select.GroupBy.NewIfChange(Visit);
            Alias newAlias = aliasMap.TryGetC(select.Alias) ?? select.Alias;

            if (top != select.Top || from != select.From || where != select.Where || columns != select.Columns || orderBy != select.OrderBy || groupBy != select.GroupBy || newAlias != select.Alias)
                return new SelectExpression(newAlias, select.IsDistinct, top, columns, from, where, orderBy, groupBy, select.SelectOptions);

            return select;
        }
开发者ID:nuub666,项目名称:framework,代码行数:15,代码来源:AliasReplacer.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# SelectFileDialog类代码示例发布时间:2022-05-24
下一篇:
C# SelectDest类代码示例发布时间: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