//Sync execution of query via direct invoke on IQueryProvider.
        public object Execute(Expression expression)
        {
            Type cosmosQueryType = typeof(CosmosLinqQuery <bool>).GetGenericTypeDefinition().MakeGenericType(typeof(object));
            CosmosLinqQuery <object> documentQuery = (CosmosLinqQuery <object>)Activator.CreateInstance(
                cosmosQueryType,
                this.container,
                this.cosmosJsonSerializer,
                this.queryClient,
                this.cosmosQueryRequestOptions,
                this.allowSynchronousQueryExecution);

            return(documentQuery.ToList().FirstOrDefault());
        }
        public TResult Execute <TResult>(Expression expression)
        {
            Type cosmosQueryType = typeof(CosmosLinqQuery <bool>).GetGenericTypeDefinition().MakeGenericType(typeof(TResult));
            CosmosLinqQuery <TResult> cosmosLINQQuery = (CosmosLinqQuery <TResult>)Activator.CreateInstance(
                cosmosQueryType,
                this.container,
                this.cosmosJsonSerializer,
                this.queryClient,
                this.cosmosQueryRequestOptions,
                expression,
                this.allowSynchronousQueryExecution);

            this.onExecuteScalarQueryCallback?.Invoke(cosmosLINQQuery);
            return(cosmosLINQQuery.ToList().FirstOrDefault());
        }
Example #3
0
        //Sync execution of query via direct invoke on IQueryProvider.
        public object Execute(Expression expression)
        {
            Type cosmosQueryType = typeof(CosmosLinqQuery <bool>).GetGenericTypeDefinition().MakeGenericType(typeof(object));
            CosmosLinqQuery <object> cosmosLINQQuery = (CosmosLinqQuery <object>)Activator.CreateInstance(
                cosmosQueryType,
                this.container,
                this.responseFactory,
                this.queryClient,
                this.continuationToken,
                this.cosmosQueryRequestOptions,
                this.allowSynchronousQueryExecution);

            this.onExecuteScalarQueryCallback?.Invoke(cosmosLINQQuery);
            return(cosmosLINQQuery.ToList().FirstOrDefault());
        }