コード例 #1
0
        public S Execute <S>(Expression expression)
        {
            var visitor = new ChangeSourceExpressionVisitor();

            Expression newExpression = visitor.Visit(expression);

            object result = _source.Provider.Execute(newExpression);

            if (result != null && _source.ElementType == typeof(S))
            {
                result = (S)_wrappingMethodInfo.Invoke(null, new [] { result });
            }
            return((S)result);
        }
コード例 #2
0
        private IEnumerable <T> BuildEnumerable()
        {
            if (_innerEnumerable == null)
            {
                lock (this) {
                    if (_innerEnumerable == null)
                    {
                        var visitor = new ChangeSourceExpressionVisitor();

                        Expression newExpression = visitor.Visit(_currentExpression);

                        var result = (IQueryable <T>)_source.Provider.CreateQuery(newExpression);

                        Verify.IsNotNull(result, "Failed to create an enumerator");

                        Thread.MemoryBarrier();
                        _innerEnumerable = result;
                    }
                }
            }

            return(_innerEnumerable);
        }