コード例 #1
0
        private void Translate(TransformationNode transformation)
        {
            switch (transformation.Kind)
            {
            case TransformationNodeKind.Aggregate:
                query.Append(ExpressionConstants.KeywordAggregate);
                break;

            case TransformationNodeKind.GroupBy:
                query.Append(ExpressionConstants.KeywordGroupBy);
                break;

            case TransformationNodeKind.Filter:
                query.Append(ExpressionConstants.KeywordFilter);
                break;

            case TransformationNodeKind.Compute:
                query.Append(ExpressionConstants.KeywordCompute);
                break;

            default:
                throw new NotSupportedException("unknown TransformationNodeKind value " + transformation.Kind.ToString());
            }

            query.Append(ExpressionConstants.SymbolOpenParen);

            GroupByTransformationNode   groupByTransformation;
            AggregateTransformationNode aggTransformation;
            FilterTransformationNode    filterTransformation;
            ComputeTransformationNode   computeTransformation;

            if ((groupByTransformation = transformation as GroupByTransformationNode) != null)
            {
                Translate(groupByTransformation);
            }
            else if ((aggTransformation = transformation as AggregateTransformationNode) != null)
            {
                Translate(aggTransformation);
            }
            else if ((filterTransformation = transformation as FilterTransformationNode) != null)
            {
                Translate(filterTransformation);
            }
            else if ((computeTransformation = transformation as ComputeTransformationNode) != null)
            {
                Translate(computeTransformation);
            }
            else
            {
                throw new NotSupportedException("unknown TransformationNode type " + transformation.GetType().Name);
            }

            query.Append(ExpressionConstants.SymbolClosedParen);
        }
コード例 #2
0
        private bool CompareTransformation(TransformationNode node1, TransformationNode node2)
        {
            if (node1.GetType() != node2.GetType())
            {
                return(false);
            }

            if (node1 is GroupByTransformationNode)
            {
                if (!CompareGroupBy(node1 as GroupByTransformationNode, node2 as GroupByTransformationNode))
                {
                    return(false);
                }
            }
            else if (node1 is AggregateTransformationNode)
            {
                if (!CompareAggregate(node1 as AggregateTransformationNode, node2 as AggregateTransformationNode))
                {
                    return(false);
                }
            }
            else if (node1 is FilterTransformationNode)
            {
                FilterClause filter1 = (node1 as FilterTransformationNode).FilterClause;
                FilterClause filter2 = (node2 as FilterTransformationNode).FilterClause;
                if (!CompareFilter(filter1, filter2, false))
                {
                    return(false);
                }
            }
            else
            {
                throw new NotSupportedException();
            }

            return(true);
        }