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


C# JoinExpression类代码示例

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


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

示例1: VisitJoin

 protected override Expression VisitJoin(JoinExpression join)
 {
     if (join.Join == JoinType.SingletonLeftOuter)
     {
         // first visit right side w/o looking at condition
         Expression right = this.Visit(join.Right);
         AliasedExpression ax = right as AliasedExpression;
         if (ax != null && !this.allColumnsUsed.ContainsKey(ax.Alias))
         {
             // if nothing references the alias on the right, then the join is redundant
             return this.Visit(join.Left);
         }
         // otherwise do it the right way
         Expression cond = this.Visit(join.Condition);
         Expression left = this.Visit(join.Left);
         right = this.Visit(join.Right);
         return this.UpdateJoin(join, join.Join, left, right, cond);
     }
     else
     {
         // visit join in reverse order
         Expression condition = this.Visit(join.Condition);
         Expression right = this.VisitSource(join.Right);
         Expression left = this.VisitSource(join.Left);
         return this.UpdateJoin(join, join.Join, left, right, condition);
     }
 }
开发者ID:CMONO,项目名称:elinq,代码行数:27,代码来源:UnusedColumnRemover.cs

示例2: VisitMemberAccess

        protected override Expression VisitMemberAccess(MemberExpression m)
        {
            Expression source = this.Visit(m.Expression);

            if (this.mapping.IsRelationship(m.Member))
            {
                ProjectionExpression projection = (ProjectionExpression)this.Visit(this.mapping.GetMemberExpression(source, m.Member));
                if (this.currentFrom != null && this.mapping.IsSingletonRelationship(m.Member))
                {
                    // convert singleton associations directly to OUTER APPLY
                    projection = projection.AddOuterJoinTest();
                    Expression newFrom = new JoinExpression(JoinType.OuterApply, this.currentFrom, projection.Source, null);
                    this.currentFrom = newFrom;
                    return projection.Projector;
                }
                return projection;
            }
            else
            {
                Expression result = QueryBinder.BindMember(source, m.Member);
                MemberExpression mex = result as MemberExpression;
                if (mex != null && mex.Member == m.Member && mex.Expression == m.Expression)
                {
                    return m;
                }
                return result;
            }
        }
开发者ID:hamdouchi97,项目名称:Stump.ORM,代码行数:28,代码来源:RelationshipBinder.cs

示例3: FindSimilarRight

		private Expression FindSimilarRight(JoinExpression join, JoinExpression compareTo)
		{
			if (join == null)
			{
				return null;
			}
			if (join.Join == compareTo.Join)
			{
				if (join.Right.NodeType == compareTo.Right.NodeType && DbExpressionComparer.AreEqual(join.Right, compareTo.Right))
				{
					if (join.Condition == compareTo.Condition)
					{
						return join.Right;
					}
					var scope = new ScopedDictionary<TableAlias, TableAlias>(null);
					scope.Add(((AliasedExpression)join.Right).Alias, ((AliasedExpression)compareTo.Right).Alias);
					if (DbExpressionComparer.AreEqual(null, scope, join.Condition, compareTo.Condition))
					{
						return join.Right;
					}
				}
			}
			Expression result = FindSimilarRight(join.Left as JoinExpression, compareTo);
			if (result == null)
			{
				result = FindSimilarRight(join.Right as JoinExpression, compareTo);
			}
			return result;
		}
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm.Linq,代码行数:29,代码来源:RedundantJoinRemover.cs

示例4: VisitMemberAccess

        protected override Expression VisitMemberAccess(MemberExpression m)
        {
            Expression source = this.Visit(m.Expression);
            EntityExpression ex = source as EntityExpression;
            IMemberMapping mm = null;

            if (ex != null && (mm = ex.Entity.Get(m.Member)) != null && mm.IsRelationship)
            {
                ProjectionExpression projection = (ProjectionExpression)this.Visit(this.expressionBuilder.GetMemberExpression(source, ex.Entity, m.Member));
                if (this.currentFrom != null && mm.IsManyToOne)
                {
                    // convert singleton associations directly to OUTER APPLY
                    projection = this.expressionBuilder.AddOuterJoinTest(projection);
                    Expression newFrom = new JoinExpression(JoinType.OuterApply, this.currentFrom, projection.Select, null);
                    this.currentFrom = newFrom;
                    return projection.Projector;
                }
                return projection;
            }
            else
            {
                Expression result = QueryBinder.BindMember(source, m.Member);
                MemberExpression mex = result as MemberExpression;
                if (mex != null && mex.Member == m.Member && mex.Expression == m.Expression)
                {
                    return m;
                }
                return result;
            }
        }
开发者ID:jaykizhou,项目名称:elinq,代码行数:30,代码来源:RelationshipBinder.cs

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

示例6: VisitJoin

 protected override Expression VisitJoin(JoinExpression join)
 {
     // visit join in reverse order
     Expression condition = this.Visit(join.Condition);
     Expression right = this.VisitSource(join.Right);
     Expression left = this.VisitSource(join.Left);
     if (left != join.Left || right != join.Right || condition != join.Condition)
     {
         return new JoinExpression(join.Join, left, right, condition);
     }
     return join;
 }
开发者ID:6nop,项目名称:SubSonic-3.0,代码行数:12,代码来源:UnusedColumnRemover.cs

示例7: VisitJoin

        protected override Expression VisitJoin(JoinExpression join)
        {
            if (join.Condition != null)
                this.Visit(join.Condition);
            else
                this.VisitSource(join.Right);

            SourceExpression left = this.VisitSource(join.Left);
            SourceExpression right = this.VisitSource(join.Right);
            Expression condition = this.Visit(join.Condition);
            if (left != join.Left || right != join.Right || condition != join.Condition)
            {
                return new JoinExpression(join.JoinType, left, right, condition);
            }
            return join;
        }
开发者ID:nuub666,项目名称:framework,代码行数:16,代码来源:QueryRebinder.cs

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

示例9: VisitJoin

        protected override Expression VisitJoin(JoinExpression join)
        {
            join = (JoinExpression)base.VisitJoin(join);

            if (join.Join == JoinType.CrossApply || join.Join == JoinType.OuterApply)
            {
                if (join.Right is TableExpression)
                {
                    return new JoinExpression(JoinType.CrossJoin, join.Left, join.Right, null);
                }
                else
                {
                    SelectExpression select = join.Right as SelectExpression;
                    // Only consider rewriting cross apply if
                    //   1) right side is a select
                    //   2) other than in the where clause in the right-side select, no left-side declared aliases are referenced
                    //   3) and has no behavior that would change semantics if the where clause is removed (like groups, aggregates, take, skip, etc).
                    // Note: it is best to attempt this after redundant subqueries have been removed.
                    if (select != null
                        && select.Take == null
                        && select.Skip == null
                        && !AggregateChecker.HasAggregates(select)
                        && (select.GroupBy == null || select.GroupBy.Count == 0))
                    {
                        SelectExpression selectWithoutWhere = select.SetWhere(null);
                        HashSet<TableAlias> referencedAliases = ReferencedAliasGatherer.Gather(selectWithoutWhere);
                        HashSet<TableAlias> declaredAliases = DeclaredAliasGatherer.Gather(join.Left);
                        referencedAliases.IntersectWith(declaredAliases);
                        if (referencedAliases.Count == 0)
                        {
                            Expression where = select.Where;
                            select = selectWithoutWhere;
                            var pc = ColumnProjector.ProjectColumns(this.CanBeColumn, where, select.Columns, select.Alias, DeclaredAliasGatherer.Gather(select.From));
                            select = select.SetColumns(pc.Columns);
                            where = pc.Projector;
                            JoinType jt = (where == null) ? JoinType.CrossJoin : (join.Join == JoinType.CrossApply ? JoinType.InnerJoin : JoinType.LeftOuter);
                            return new JoinExpression(jt, join.Left, select, where);
                        }
                    }
                }
            }

            return join;
        }
开发者ID:maravillas,项目名称:linq-to-delicious,代码行数:44,代码来源:CrossApplyRewriter.cs

示例10: VisitJoin

        protected override Expression VisitJoin(JoinExpression join)
        {
            VisitSource(join.Left);
            switch (join.Join)
            {
                case JoinType.CrossJoin:
                    sb.Append("CROSS JOIN ");
                    break;
                case JoinType.InnerJoin:
                    sb.Append("INNER JOIN ");
                    break;
                case JoinType.CrossApply:
                    sb.Append("CROSS APPLY ");
                    break;
                case JoinType.OuterApply:
                    sb.Append("OUTER APPLY ");
                    break;
                case JoinType.LeftOuter:
                    sb.Append("LEFT OUTER JOIN ");
                    break;
            }
            VisitSource(join.Right);
            if (join.Condition == null)
            {
                return join;
            }

            sb.Append("ON ");
            VisitPredicate(join.Condition);
            return join;
        }
开发者ID:ScottWeinstein,项目名称:Linq2KdbQ,代码行数:31,代码来源:QFormatter.cs

示例11: KeysJoin

            private static IEnumerable<ColumnExpression> KeysJoin(JoinExpression join)
            {
                switch (join.JoinType)
                {
                    case JoinType.SingleRowLeftOuterJoin:
                        return Keys(join.Left);

                    case JoinType.CrossJoin:
                    case JoinType.InnerJoin:
                    case JoinType.CrossApply:
                    case JoinType.OuterApply:
                    case JoinType.LeftOuterJoin:
                    case JoinType.RightOuterJoin:
                    case JoinType.FullOuterJoin:
                        return Keys(join.Left).Concat(Keys(join.Right));
                    default:
                        break;
                }

                throw new InvalidOperationException("Unexpected Join Type");
            }
开发者ID:nuub666,项目名称:framework,代码行数:21,代码来源:ChildProjectionFlattener.cs

示例12: VisitJoin

 protected virtual Expression VisitJoin(JoinExpression join)
 {
     Expression left = this.VisitSource(join.Left);
     Expression right = this.VisitSource(join.Right);
     Expression condition = this.Visit(join.Condition);
     if (left != join.Left || right != join.Right || condition != join.Condition)
     {
         return new JoinExpression(join.Join, left, right, condition);
     }
     return join;
 }
开发者ID:RyanDansie,项目名称:SubSonic-3.0,代码行数:11,代码来源:DbExpressionVisitor.cs

示例13: CompareJoin

        protected virtual bool CompareJoin(JoinExpression a, JoinExpression b)
        {
            if (a.Join != b.Join || !this.Compare(a.Left, b.Left))
                return false;

            if (a.Join == JoinType.CrossApply || a.Join == JoinType.OuterApply)
            {
                var save = this.aliasScope;
                try
                {
                    this.aliasScope = new ScopedDictionary<TableAlias, TableAlias>(this.aliasScope);
                    this.MapAliases(a.Left, b.Left);

                    return this.Compare(a.Right, b.Right)
                        && this.Compare(a.Condition, b.Condition);
                }
                finally
                {
                    this.aliasScope = save;
                }
            }
            else
            {
                return this.Compare(a.Right, b.Right)
                    && this.Compare(a.Condition, b.Condition);
            }
        }
开发者ID:jogibear9988,项目名称:IQToolkit,代码行数:27,代码来源:DbExpressionComparer.cs

示例14: BindJoin

 protected virtual Expression BindJoin(Type resultType, Expression outerSource, Expression innerSource, LambdaExpression outerKey, LambdaExpression innerKey, LambdaExpression resultSelector)
 {
     ProjectionExpression outerProjection = this.VisitSequence(outerSource);
     ProjectionExpression innerProjection = this.VisitSequence(innerSource);
     this.map[outerKey.Parameters[0]] = outerProjection.Projector;
     Expression outerKeyExpr = this.Visit(outerKey.Body);
     this.map[innerKey.Parameters[0]] = innerProjection.Projector;
     Expression innerKeyExpr = this.Visit(innerKey.Body);
     this.map[resultSelector.Parameters[0]] = outerProjection.Projector;
     this.map[resultSelector.Parameters[1]] = innerProjection.Projector;
     Expression resultExpr = this.Visit(resultSelector.Body);
     JoinExpression join = new JoinExpression(JoinType.InnerJoin, outerProjection.Select, innerProjection.Select, outerKeyExpr.Equal(innerKeyExpr));
     var alias = this.GetNextAlias();
     ProjectedColumns pc = this.ProjectColumns(resultExpr, alias, outerProjection.Select.Alias, innerProjection.Select.Alias);
     return new ProjectionExpression(
         new SelectExpression(alias, pc.Columns, join, null),
         pc.Projector
         );
 }
开发者ID:RukaiYu,项目名称:EnterpriseDevelopmentFx,代码行数:19,代码来源:QueryBinder.cs

示例15: VisitJoin

 protected virtual Expression VisitJoin(JoinExpression join)
 {
     var left = this.VisitSource(join.Left);
     var right = this.VisitSource(join.Right);
     var condition = this.Visit(join.Condition);
     return this.UpdateJoin(join, join.Join, left, right, condition);
 }
开发者ID:bisand,项目名称:NetCouch,代码行数:7,代码来源:DbExpressionVisitor.cs


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