コード例 #1
0
        public virtual Expression ReplaceClauseReferences(
            [NotNull] Expression expression,
            [CanBeNull] IQuerySource querySource = null,
            bool inProjection = false)
        {
            Check.NotNull(expression, nameof(expression));

            expression
                = _entityQueryableExpressionVisitorFactory
                  .Create(this, querySource)
                  .Visit(expression);

            expression
                = _memberAccessBindingExpressionVisitorFactory
                  .Create(QueryCompilationContext.QuerySourceMapping, this, inProjection)
                  .Visit(expression);

            if (!inProjection)
            {
                expression
                    = QueryCompilationContext.LinqOperatorProvider
                      .AdjustSequenceType(expression);
            }

            return(expression);
        }
コード例 #2
0
        public virtual Expression ReplaceClauseReferences(
            [NotNull] Expression expression,
            [CanBeNull] IQuerySource querySource = null,
            bool inProjection = false)
        {
            Check.NotNull(expression, nameof(expression));

            expression
                = _entityQueryableExpressionVisitorFactory
                  .Create(this, querySource)
                  .Visit(expression);

            expression
                = _memberAccessBindingExpressionVisitorFactory
                  .Create(QueryCompilationContext.QuerySourceMapping, this, inProjection)
                  .Visit(expression);

            if (!inProjection &&
                expression.Type != typeof(string) &&
                expression.Type != typeof(byte[]) &&
                _expression?.Type.TryGetElementType(typeof(IAsyncEnumerable <>)) != null)
            {
                var elementType = expression.Type.TryGetElementType(typeof(IEnumerable <>));

                if (elementType != null)
                {
                    return
                        (Expression.Call(
                             AsyncLinqOperatorProvider
                             .ToAsyncEnumerableMethod
                             .MakeGenericMethod(elementType),
                             expression));
                }
            }

            return(expression);
        }