private bool TryRewrite(SubQueryExpression subQueryExpression, bool forceToListResult, out Expression result)
        {
            if (_queryCompilationContext.TryGetCorrelatedSubqueryMetadata(subQueryExpression.QueryModel.MainFromClause, out var correlatedSubqueryMetadata))
            {
                var parentQsre = new QuerySourceReferenceExpression(correlatedSubqueryMetadata.ParentQuerySource);
                result = Rewrite(
                    correlatedSubqueryMetadata.Index,
                    subQueryExpression.QueryModel,
                    correlatedSubqueryMetadata.CollectionNavigation,
                    correlatedSubqueryMetadata.TrackingQuery,
                    parentQsre,
                    forceToListResult);

                return(true);
            }

            result = null;

            return(false);
        }
Пример #2
0
        private bool TryRewrite(SubQueryExpression subQueryExpression, bool forceToListResult, Type listResultElementType, out Expression result)
        {
            if (_queryCompilationContext.TryGetCorrelatedSubqueryMetadata(subQueryExpression.QueryModel.MainFromClause, out var correlatedSubqueryMetadata) &&
                subQueryExpression.QueryModel.BodyClauses.OfType <WhereClause>()
                .Any(c => c.Predicate is NullSafeEqualExpression))
            {
                var parentQsre = new QuerySourceReferenceExpression(correlatedSubqueryMetadata.ParentQuerySource);
                result = Rewrite(
                    correlatedSubqueryMetadata.Index,
                    subQueryExpression.QueryModel,
                    correlatedSubqueryMetadata.CollectionNavigation,
                    correlatedSubqueryMetadata.TrackingQuery,
                    parentQsre,
                    forceToListResult,
                    listResultElementType);

                return(true);
            }

            result = null;

            return(false);
        }