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

C# JoinExpression类代码示例

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

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



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


示例16: VisitJoin

 protected override Expression VisitJoin(JoinExpression join)
 {
     this.VisitJoinLeft(join.Left);
     this.WriteLine(Indentation.Same);
     switch (join.Join)
     {
         case JoinType.CrossJoin:
             this.Write("CROSS JOIN ");
             break;
         case JoinType.InnerJoin:
             this.Write("INNER JOIN ");
             break;
         case JoinType.CrossApply:
             this.Write("CROSS APPLY ");
             break;
         case JoinType.OuterApply:
             this.Write("OUTER APPLY ");
             break;
         case JoinType.LeftOuter:
         case JoinType.SingletonLeftOuter:
             this.Write("LEFT OUTER JOIN ");
             break;
     }
     this.VisitJoinRight(join.Right);
     if (join.Condition != null)
     {
         this.WriteLine(Indentation.Inner);
         this.Write("ON ");
         this.VisitPredicate(join.Condition);
         this.Indent(Indentation.Outer);
     }
     return join;
 }
开发者ID:firestrand,项目名称:IQToolkit,代码行数:33,代码来源:SqlFormatter.cs


示例17: VisitJoin

        protected override Expression VisitJoin(JoinExpression join)
        {
            SourceExpression left = this.VisitSource(join.Left);

            ReadOnlyCollection<OrderExpression> leftOrders = this.gatheredOrderings;
            this.gatheredOrderings = null;

            SourceExpression right = join.Right is TableExpression ? join.Right : this.VisitSource(join.Right);

            this.PrependOrderings(leftOrders);

            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,代码行数:19,代码来源:OrderByRewriter.cs


示例18: VisitJoin

        protected override Expression VisitJoin(JoinExpression join)
        {
            this.VisitSource(join.Left);
            this.AppendNewLine(Indentation.Same);
            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;
            }
            this.VisitSource(join.Right);
            if (join.Condition != null)
            {
                this.AppendNewLine(Indentation.Inner);
                sb.Append("ON ");

                var binaryExpr = join.Condition as BinaryExpression;

                if (binaryExpr != null
                    && binaryExpr.Left.NodeType == ExpressionType.New
                    && binaryExpr.Right.NodeType == ExpressionType.New)
                {
                    var leftNew = binaryExpr.Left as NewExpression;
                    var rightNew = binaryExpr.Right as NewExpression;

                    if (leftNew.Arguments.Count != rightNew.Arguments.Count)
                        throw new Exception("Anonymous types in join clauses must have the same number of arguments.");

                    for (int i = 0; i < leftNew.Arguments.Count; i++)
                    {
                        if (i != 0)
                            sb.Append(" AND ");

                        this.VisitPredicate(BinaryExpression.Equal(leftNew.Arguments[i], rightNew.Arguments[i]));

                        sb.Append(" ");
                    }
                }
                else
                {
                    this.VisitPredicate(join.Condition);
                }

                this.Indent(Indentation.Outer);
            }
            return join;
        }
开发者ID:ajepst,项目名称:SubSonic-3.0,代码行数:59,代码来源:TSqlFormatter.cs


示例19: GetInsertResult

 protected override Expression GetInsertResult(MappingEntity entity, Expression instance,
                                               LambdaExpression selector, Dictionary<MemberInfo, Expression> map)
 {
     var tables = _mapping.GetTables(entity);
     if (tables.Count <= 1)
     {
         return base.GetInsertResult(entity, instance, selector, map);
     }
     var aliases = new Dictionary<string, TableAlias>();
     MappingTable rootTable = tables.Single(ta => !_mapping.IsExtensionTable(ta));
     var tableExpression = new TableExpression(new TableAlias(), entity, _mapping.GetTableName(rootTable));
     var aggregator = Aggregator.GetAggregator(selector.Body.Type,
                                               typeof (IEnumerable<>).MakeGenericType(selector.Body.Type));
     aliases.Add(_mapping.GetAlias(rootTable), tableExpression.Alias);
     Expression source = tableExpression;
     foreach (MappingTable table in tables.Where(t => _mapping.IsExtensionTable(t)))
     {
         TableAlias joinedTableAlias = new TableAlias();
         string extensionAlias = _mapping.GetAlias(table);
         aliases.Add(extensionAlias, joinedTableAlias);
         List<string> keyColumns = _mapping.GetExtensionKeyColumnNames(table).ToList();
         List<MemberInfo> relatedMembers = _mapping.GetExtensionRelatedMembers(table).ToList();
         string relatedAlias = _mapping.GetExtensionRelatedAlias(table);
         TableAlias relatedTableAlias;
         aliases.TryGetValue(relatedAlias, out relatedTableAlias);
         TableExpression joinedTex = new TableExpression(joinedTableAlias, entity, _mapping.GetTableName(table));
         Expression cond = null;
         for (int i = 0, n = keyColumns.Count; i < n; i++)
         {
             var memberType = TypeHelper.GetMemberType(relatedMembers[i]);
             var colType = GetColumnType(entity, relatedMembers[i]);
             var relatedColumn = new ColumnExpression(memberType, colType, relatedTableAlias,
                                                      _mapping.GetColumnName(entity, relatedMembers[i]));
             var joinedColumn = new ColumnExpression(memberType, colType, joinedTableAlias, keyColumns[i]);
             var eq = joinedColumn.Equal(relatedColumn);
             cond = (cond != null) ? cond.And(eq) : eq;
         }
         source = new JoinExpression(JoinType.SingletonLeftOuter, source, joinedTex, cond);
     }
     Expression where;
     DeclarationCommand genIdCommand = null;
     var generatedIds =
         _mapping.GetMappedMembers(entity).Where(
             m => _mapping.IsPrimaryKey(entity, m) && _mapping.IsGenerated(entity, m)).ToList();
     if (generatedIds.Count > 0)
     {
         if (map == null || !generatedIds.Any(m => map.ContainsKey(m)))
         {
             var localMap = new Dictionary<MemberInfo, Expression>();
             genIdCommand = GetGeneratedIdCommand(entity, generatedIds.ToList(), localMap);
             map = localMap;
         }
         var mex = selector.Body as MemberExpression;
         if (mex != null && _mapping.IsPrimaryKey(entity, mex.Member) && _mapping.IsGenerated(entity, mex.Member))
         {
             if (genIdCommand != null)
             {
                 return new ProjectionExpression(
                     genIdCommand.Source,
                     new ColumnExpression(mex.Type, genIdCommand.Variables[0].QueryType,
                                          genIdCommand.Source.Alias, genIdCommand.Source.Columns[0].Name),
                     aggregator
                     );
             }
             TableAlias alias = new TableAlias();
             var colType = GetColumnType(entity, mex.Member);
             return new ProjectionExpression(
                 new SelectExpression(alias, new[] {new ColumnDeclaration("", map[mex.Member], colType)},
                                      null, null),
                 new ColumnExpression(TypeHelper.GetMemberType(mex.Member), colType, alias, ""),
                 aggregator
                 );
         }
         where = generatedIds.Select((m, i) =>
                                     GetMemberExpression(source, entity, m).Equal(map[m])
             ).Aggregate((x, y) => x.And(y));
     }
     else
     {
         where = GetIdentityCheck(tableExpression, entity, instance);
     }
     var columns = new List<ColumnDeclaration>();
     GetColumns(entity, aliases, columns);
     SelectExpression root = new SelectExpression(new TableAlias(), columns, source, null);
     Expression typeProjector = GetEntityExpression(tableExpression, entity);
     Expression selection = DbExpressionReplacer.Replace(selector.Body, selector.Parameters[0], typeProjector);
     TableAlias newAlias = new TableAlias();
     var pc = ColumnProjector.ProjectColumns(Translator.Linguist.Language, selection, null, newAlias,
                                             tableExpression.Alias);
     var pe = new ProjectionExpression(
         new SelectExpression(newAlias, pc.Columns, root, where),
         pc.Projector,
         aggregator
         );
     if (genIdCommand != null)
     {
         return new BlockCommand(genIdCommand, pe);
     }
     return pe;
 }
开发者ID:firestrand,项目名称:IQToolkit,代码行数:100,代码来源:AdvancedMapping.cs


示例20: VisitJoin

        protected internal override Expression VisitJoin(JoinExpression join)
        {
            if (join.JoinType == JoinType.SingleRowLeftOuterJoin)
            {
                var source = join.Right as SourceWithAliasExpression;

                var hs = allColumnsUsed.TryGetC(source.Alias);

                if (hs == null || hs.Count == 0)
                    return Visit(join.Left);
            }

            if (join.JoinType == JoinType.OuterApply ||join.JoinType == JoinType.LeftOuterJoin)
            {
                var sql = join.Right as SelectExpression;

                if (sql != null && sql.IsOneRow())
                {
                    var hs = allColumnsUsed.TryGetC(sql.Alias);
                    if (hs == null || hs.Count == 0)
                        return Visit(join.Left);
                }
            }

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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