コード例 #1
0
            protected internal override Node VisitApplySource([NotNull] ApplySource node)
            {
                this.Visit(node.Left);

                this.Builder.Append("  " + (node.IsOuterApply ? "OUTER" : "CROSS") + " ");

                this.Visit(node.Right);

                return(node);
            }
コード例 #2
0
            protected internal override Node VisitApplySource(ApplySource node)
            {
                node = (ApplySource)base.VisitApplySource(node);

                Expression factory = Expression.Constant(null, typeof(Func <Row, DataSource>));

                var left     = this.data.GetFactoryExpression(node.Left);
                var right    = this.data.GetFactoryExpression(node.Right);
                var row      = Expression.Parameter(typeof(Row), "row");
                var replaced = GenericVisitor.Visit(
                    (SourceFieldExpression e) => Expression.Call(row, NodeDataProviderDataSourceConverter.GetMethod.MakeGenericMethod(e.Type), Expression.Constant($"{e.SourceName}.{e.FieldName}")),
                    (UnaryExpression e) => e.NodeType == ExpressionType.Convert && e.Operand is SourceFieldExpression
                                               ? Expression.Call(row, NodeDataProviderDataSourceConverter.GetMethod.MakeGenericMethod(e.Type), Expression.Constant($"{((SourceFieldExpression)e.Operand).SourceName}.{((SourceFieldExpression)e.Operand).FieldName}"))
                                               : null,
                    right);

                if (!ReferenceEquals(replaced, right))
                {
                    factory = Expression.Constant(right);
                    right   = GenericVisitor.Visit(
                        (SourceFieldExpression e) => Expression.Default(e.Type),
                        (UnaryExpression e) => e.NodeType == ExpressionType.Convert && e.Operand is SourceFieldExpression
                                                   ? Expression.Default(e.Type)
                                                   : null,
                        right);
                }

                var apply =
                    node.IsOuterApply
                        ? Evaluator.CreateJoin(
                        typeof(OuterApply).GetTypeInfo().DeclaredConstructors.First(),
                        left,
                        right,
                        factory)
                        : Evaluator.CreateJoin(
                        typeof(CrossApply).GetTypeInfo().DeclaredConstructors.First(),
                        left,
                        right,
                        factory);

                this.data.SetFactoryExpression(node, apply);

                return(node);
            }
コード例 #3
0
ファイル: NodeVisitor.cs プロジェクト: MaartenX/ConnectQl
 /// <summary>
 /// Visits a <see cref="ApplySource"/>.
 /// </summary>
 /// <param name="node">
 /// The node.
 /// </param>
 /// <returns>
 /// The node, or a new version of the node.
 /// </returns>
 protected internal virtual Node VisitApplySource([NotNull] ApplySource node)
 {
     return(node.VisitChildren(this));
 }
コード例 #4
0
 /// <summary>
 /// Visits a <see cref="ApplySource"/>.
 /// </summary>
 /// <param name="node">
 /// The node.
 /// </param>
 /// <returns>
 /// The node, or a new version of the node.
 /// </returns>
 protected internal override Node VisitApplySource(ApplySource node)
 {
     return(this.VisitImplementation(node) ?? base.VisitApplySource(node));
 }