Example #1
0
        private ParameterizedQuery GetScalarQuery <TResult>(
            Func <QueryEndpoint, TResult> query, bool executeAsSideEffect, out TResult result)
        {
            AllocateParameterAndReplacer();

            var parameterContext = new ParameterContext(outerContext);

            parameterContext.SetValue(queryParameter, queryTarget);
            var scope = new CompiledQueryProcessingScope(
                queryParameter, queryParameterReplacer, parameterContext, executeAsSideEffect);

            using (scope.Enter()) {
                result = query.Invoke(endpoint);
            }

            var parameterizedQuery = (ParameterizedQuery)scope.ParameterizedQuery;

            if (parameterizedQuery == null && queryTarget != null)
            {
                throw new NotSupportedException(Strings.ExNonLinqCallsAreNotSupportedWithinQueryExecuteDelayed);
            }

            PutCachedQuery(parameterizedQuery);
            return(parameterizedQuery);
        }
 public ThreadBindingToken(CompiledQueryProcessingScope scope)
 {
     if (Current != null)
     {
         throw new InvalidOperationException(
                   string.Format(Strings.ExXNestingIsNotSupported, nameof(CompiledQueryProcessingScope)));
     }
     Current = scope;
 }
Example #3
0
        private ParameterizedQuery GetSequenceQuery <TElement>(
            Func <QueryEndpoint, IQueryable <TElement> > query)
        {
            var parameterizedQuery = GetCachedQuery();

            if (parameterizedQuery != null)
            {
                return(parameterizedQuery);
            }

            AllocateParameterAndReplacer();
            var scope = new CompiledQueryProcessingScope(queryParameter, queryParameterReplacer);

            using (scope.Enter()) {
                var result          = query.Invoke(endpoint);
                var translatedQuery = endpoint.Provider.Translate(result.Expression);
                parameterizedQuery = (ParameterizedQuery)translatedQuery;
            }

            PutCachedQuery(parameterizedQuery);
            return(parameterizedQuery);
        }