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


C# ProjectionExpression类代码示例

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


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

示例1: 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

示例2: VisitProjection

 protected override Expression VisitProjection(ProjectionExpression proj)
 {
     if (proj != root)
         return AliasReplacer.Replace(base.VisitProjection(proj), aliasGenerator);
     else
         return (ProjectionExpression)base.VisitProjection(proj);
 }
开发者ID:nuub666,项目名称:framework,代码行数:7,代码来源:AliasProjectionReplacer.cs

示例3: ProviderQueryExpression

 public ProviderQueryExpression(
     IEnumerable<ProviderPropertyExpression> providerProperties,
     ProjectionExpression projection,
     PredicateExpression predicate,
     SortExpressionCollectionExpression sort)
     : this(new ProviderPropertiesExpression(providerProperties), projection, predicate, sort)
 { }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:7,代码来源:ProviderQueryExpression.cs

示例4: AddOuterJoinTest

 public virtual ProjectionExpression AddOuterJoinTest(ProjectionExpression proj)
 {
     var test = this.GetOuterJoinTest(proj.Select);
     var select = proj.Select;
     ColumnExpression testCol = null;
     // look to see if test expression exists in columns already
     foreach (var col in select.Columns)
     {
         if (test.Equals(col.Expression))
         {
             var colType = SqlType.Get(test.Type);
             testCol = new ColumnExpression(test.Type, colType, select.Alias, col.Name);
             break;
         }
     }
     if (testCol == null)
     {
         // add expression to projection
         testCol = test as ColumnExpression;
         string colName = (testCol != null) ? testCol.Name : "Test";
         colName = proj.Select.Columns.GetAvailableColumnName(colName);
         var colType = SqlType.Get(test.Type);
         select = select.AddColumn(new ColumnDeclaration(colName, test, colType));
         testCol = new ColumnExpression(test.Type, colType, select.Alias, colName);
     }
     var newProjector = new OuterJoinedExpression(testCol, proj.Projector);
     return new ProjectionExpression(select, newProjector, proj.Aggregator);
 }
开发者ID:jaykizhou,项目名称:elinq,代码行数:28,代码来源:DbExpressionBuilder.cs

示例5: UpdateClientJoin

 protected ClientJoinExpression UpdateClientJoin(ClientJoinExpression join, ProjectionExpression projection, IEnumerable<Expression> outerKey, IEnumerable<Expression> innerKey)
 {
     if (projection != join.Projection || outerKey != join.OuterKey || innerKey != join.InnerKey)
     {
         return new ClientJoinExpression(projection, outerKey, innerKey);
     }
     return join;
 }
开发者ID:bisand,项目名称:NetCouch,代码行数:8,代码来源:DbExpressionVisitor.cs

示例6: VisitProjection

 protected override Expression VisitProjection(ProjectionExpression proj)
 {
     // don't parameterize the projector or aggregator!
     SelectExpression select = (SelectExpression)this.Visit(proj.Source);
     if (select != proj.Source) {
         return new ProjectionExpression(select, proj.Projector, proj.Aggregator);
     }
     return proj;
 }
开发者ID:maravillas,项目名称:linq-to-delicious,代码行数:9,代码来源:Parameterizer.cs

示例7: VisitProjection

 protected override Expression VisitProjection(ProjectionExpression proj)
 {
     Expression projector = this.Visit(proj.Projector);
     if (projector != proj.Projector)
     {
         return new ProjectionExpression(proj.Source, projector, proj.Aggregator);
     }
     return proj;
 }
开发者ID:maravillas,项目名称:linq-to-delicious,代码行数:9,代码来源:RelationshipIncluder.cs

示例8: 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

示例9: Flatten

        static internal ProjectionExpression Flatten(ProjectionExpression proj, AliasGenerator aliasGenerator)
        {
            var result = (ProjectionExpression)new ChildProjectionFlattener { aliasGenerator = aliasGenerator }.Visit(proj);
            if (result == proj)
                return result;

            Expression columnCleaned = UnusedColumnRemover.Remove(result);
            Expression subqueryCleaned = RedundantSubqueryRemover.Remove(columnCleaned);

            return (ProjectionExpression)subqueryCleaned; 
        }
开发者ID:nuub666,项目名称:framework,代码行数:11,代码来源:ChildProjectionFlattener.cs

示例10: VisitProjection

 protected override Expression VisitProjection(ProjectionExpression projection)
 {
     // visit mapping in reverse order
     Expression projector = this.Visit(projection.Projector);
     SelectExpression source = (SelectExpression)this.Visit(projection.Source);
     if (projector != projection.Projector || source != projection.Source)
     {
         return new ProjectionExpression(source, projector, projection.Aggregator);
     }
     return projection;
 }
开发者ID:6nop,项目名称:SubSonic-3.0,代码行数:11,代码来源:UnusedColumnRemover.cs

示例11: MergeProjectionExpressions

 private static ProjectionExpression MergeProjectionExpressions(ProjectionExpression projection,
                                                                ProjectionExpression expression)
 {
     if (projection is AttributesProjectionExpression && expression is AttributesProjectionExpression)
     {
         List<PropertyNameExpression> expr = new List<PropertyNameExpression>();
         expr.AddRange((projection as AttributesProjectionExpression).Attributes.Collection);
         expr.AddRange((expression as AttributesProjectionExpression).Attributes.Collection);
         return new AttributesProjectionExpression(expr);
     }
     throw GetMergeException(projection, expression);
 }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:12,代码来源:ExpressionMerger.cs

示例12: VisitProjection

        protected override Expression VisitProjection(ProjectionExpression proj)
        {
            this.Visit(proj.Projector);

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

            if (source != proj.Select || projector != proj.Projector)
            {
                return new ProjectionExpression(source, projector, proj.UniqueFunction, proj.Type);
            }
            return proj;
        }
开发者ID:nuub666,项目名称:framework,代码行数:13,代码来源:QueryRebinder.cs

示例13: VisitClientJoin

        protected override Expression VisitClientJoin(ClientJoinExpression join)
        {
            // convert client join into a up-front lookup table builder & replace client-join in tree with lookup accessor

            // 1) lookup = query.Select(e => new KVP(key: inner, value: e)).ToLookup(kvp => kvp.Key, kvp => kvp.Value)
            Expression innerKey = MakeJoinKey(join.InnerKey);
            Expression outerKey = MakeJoinKey(join.OuterKey);

            ConstructorInfo kvpConstructor = typeof(KeyValuePair<,>).MakeGenericType(innerKey.Type, join.Projection.Projector.Type).GetConstructor(new System.Type[] { innerKey.Type, join.Projection.Projector.Type });
            Expression constructKVPair = Expression.New(kvpConstructor, innerKey, join.Projection.Projector);
            ProjectionExpression newProjection = new ProjectionExpression(join.Projection.Source, constructKVPair);

            int iLookup = ++nLookup;
            Expression execution = ExecuteProjection(newProjection, false);

            ParameterExpression kvp = Expression.Parameter(constructKVPair.Type, "kvp");

            // filter out nulls
            if (join.Projection.Projector.NodeType == (ExpressionType)DbExpressionType.OuterJoined)
            {
                LambdaExpression pred = Expression.Lambda(
                    Expression.NotEqual(
                        Expression.PropertyOrField(kvp, "Value"),
                        Expression.Constant(null, join.Projection.Projector.Type)
                        ),
                    kvp
                    );
                execution = Expression.Call(typeof(Enumerable), "Where", new System.Type[] { kvp.Type }, execution, pred);
            }

            // make lookup
            LambdaExpression keySelector = Expression.Lambda(Expression.PropertyOrField(kvp, "Key"), kvp);
            LambdaExpression elementSelector = Expression.Lambda(Expression.PropertyOrField(kvp, "Value"), kvp);
            Expression toLookup = Expression.Call(typeof(Enumerable), "ToLookup", new System.Type[] { kvp.Type, outerKey.Type, join.Projection.Projector.Type }, execution, keySelector, elementSelector);

            // 2) agg(lookup[outer])
            ParameterExpression lookup = Expression.Parameter(toLookup.Type, "lookup" + iLookup);
            PropertyInfo property = lookup.Type.GetProperty("Item");
            Expression access = Expression.Call(lookup, property.GetGetMethod(), Visit(outerKey));
            if (join.Projection.Aggregator != null)
            {
                // apply aggregator
                access = DbExpressionReplacer.Replace(join.Projection.Aggregator.Body, join.Projection.Aggregator.Parameters[0], access);
            }

            variables.Add(lookup);
            initializers.Add(toLookup);

            return access;
        }
开发者ID:ScottWeinstein,项目名称:Linq2KdbQ,代码行数:50,代码来源:QExecutionBuilder.cs

示例14: VisitProjection

 protected virtual Expression VisitProjection(ProjectionExpression projection)
 {
     this.AddAlias(projection.Source.Alias);
     this.Write("Project(");
     this.WriteLine(Indentation.Inner);
     this.Write("@\"");
     this.Visit(projection.Source);
     this.Write("\",");
     this.WriteLine(Indentation.Same);
     this.Visit(projection.Projector);
     this.Write(",");
     this.WriteLine(Indentation.Same);
     this.Visit(projection.Aggregator);
     this.WriteLine(Indentation.Outer);
     this.Write(")");
     return projection;
 }
开发者ID:hamdouchi97,项目名称:Stump.ORM,代码行数:17,代码来源:DbExpressionWriter.cs

示例15: VisitProjection

        protected override Expression VisitProjection(ProjectionExpression proj)
        {
            if (isTopLevel)
            {
                isTopLevel = false;
                currentSelect = proj.Source;
                Expression projector = Visit(proj.Projector);
                if (projector != proj.Projector || currentSelect != proj.Source)
                {
                    return new ProjectionExpression(currentSelect, projector, proj.Aggregator);
                }
                return proj;
            }

            if (proj.IsSingleton && CanJoinOnServer(currentSelect))
            {
                TableAlias newAlias = new TableAlias();
                currentSelect = currentSelect.AddRedundantSelect(newAlias);

                // remap any references to the outer select to the new alias;
                SelectExpression source =
                    (SelectExpression) ColumnMapper.Map(proj.Source, newAlias, currentSelect.Alias);

                // add outer-join test
                ProjectionExpression pex = new ProjectionExpression(source, proj.Projector).AddOuterJoinTest();

                var pc = ColumnProjector.ProjectColumns(language.CanBeColumn, pex.Projector, currentSelect.Columns,
                                                        currentSelect.Alias, newAlias, proj.Source.Alias);

                JoinExpression join = new JoinExpression(JoinType.OuterApply, currentSelect.From, pex.Source, null);

                currentSelect = new SelectExpression(currentSelect.Alias, pc.Columns, join, null);
                return Visit(pc.Projector);
            }

            var saveTop = isTopLevel;
            var saveSelect = currentSelect;
            isTopLevel = true;
            currentSelect = null;
            Expression result = base.VisitProjection(proj);
            isTopLevel = saveTop;
            currentSelect = saveSelect;
            return result;
        }
开发者ID:rodrigodom,项目名称:SubSonic-3.0,代码行数:44,代码来源:SingletonProjectionRewriter.cs


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