Ejemplo n.º 1
0
        public override void VisitQueryBody(QueryBodySyntax node)
        {
            if ((node.SelectOrGroup is SelectClauseSyntax) == false)
            {
                VisitGroupClause(node.SelectOrGroup as GroupClauseSyntax);
                return;
            }

            var selectExpressions = new Dictionary <string, ExpressionSyntax>();
            var visitor           = new CaptureSelectExpressionsAndNewFieldNamesVisitor(false, new HashSet <string>(), selectExpressions);

            node.Accept(visitor);

            _indexData.SelectExpressions = selectExpressions;
            _indexData.NumberOfSelectClauses++;
        }
Ejemplo n.º 2
0
        public override void VisitInvocationExpression(InvocationExpressionSyntax invocationExpression)
        {
            base.VisitInvocationExpression(invocationExpression);

            var selectExpressions = new Dictionary <string, ExpressionSyntax>();
            var visitor           = new CaptureSelectExpressionsAndNewFieldNamesVisitor(false, new HashSet <string>(), selectExpressions);

            invocationExpression.Accept(visitor);

            var memberAccessExpression = invocationExpression.Expression as MemberAccessExpressionSyntax;

            if (memberAccessExpression == null)
            {
                base.VisitInvocationExpression(invocationExpression);
                return;
            }

            if (memberAccessExpression.Name.Identifier.ValueText == "Where")
            {
                _indexData.HasWhere = true;
            }

            _indexData.SelectExpressions    = selectExpressions;
            _indexData.InvocationExpression = invocationExpression;
            _indexData.FromIdentifier       = (invocationExpression.ArgumentList.Arguments[0].Expression as SimpleLambdaExpressionSyntax)?.Parameter.Identifier.ValueText;

            if (memberAccessExpression.Expression is IdentifierNameSyntax identifierNameSyntax)
            {
                _indexData.Collection = identifierNameSyntax.Identifier.ValueText;
                return;
            }

            if (memberAccessExpression.Expression is MemberAccessExpressionSyntax innerMemberAccessExpression)
            {
                _indexData.Collection = innerMemberAccessExpression.Name.Identifier.ValueText;
            }
        }