internal string CreateN1QlQuery(IBucket bucket, Expression expression, ClusterVersion clusterVersion, bool selectDocumentMetadata, out ScalarResultBehavior resultBehavior) { var serializer = new Core.Serialization.DefaultSerializer(); var bucketContext = new Mock <IBucketContext>(); bucketContext.SetupGet(p => p.Bucket).Returns(bucket); bucketContext.SetupGet(p => p.Configuration).Returns(new ClientConfiguration { Serializer = () => serializer }); var queryModel = QueryParserHelper.CreateQueryParser(bucketContext.Object).GetParsedQuery(expression); var queryGenerationContext = new N1QlQueryGenerationContext() { MemberNameResolver = MemberNameResolver, MethodCallTranslatorProvider = new DefaultMethodCallTranslatorProvider(), Serializer = serializer, SelectDocumentMetadata = selectDocumentMetadata, ClusterVersion = clusterVersion }; var visitor = new N1QlQueryModelVisitor(queryGenerationContext); visitor.VisitQueryModel(queryModel); resultBehavior = visitor.ScalarResultBehavior; return(visitor.GetQuery()); }
internal string CreateN1QlQuery(IBucket bucket, Expression expression, ClusterVersion clusterVersion, bool selectDocumentMetadata, out ScalarResultBehavior resultBehavior) { var mockCluster = new Mock <ICluster>(); mockCluster .Setup(p => p.ClusterServices) .Returns(ServiceProvider); var queryModel = QueryParserHelper.CreateQueryParser(mockCluster.Object).GetParsedQuery(expression); var queryGenerationContext = new N1QlQueryGenerationContext() { MemberNameResolver = MemberNameResolver, MethodCallTranslatorProvider = new DefaultMethodCallTranslatorProvider(), Serializer = ServiceProvider.GetRequiredService <ITypeSerializer>(), SelectDocumentMetadata = selectDocumentMetadata, ClusterVersion = clusterVersion, LoggerFactory = LoggerFactory }; var visitor = new N1QlQueryModelVisitor(queryGenerationContext); visitor.VisitQueryModel(queryModel); resultBehavior = visitor.ScalarResultBehavior; return(visitor.GetQuery()); }
/// <summary> /// Creates a new LinqQueryRequest, with the given N1QL query. /// </summary> /// <param name="query">N1QL query.</param> /// <param name="scalarResultBehavior">Behaviors related to extracting results for scalar queries.</param> public LinqQueryRequest(string query, ScalarResultBehavior scalarResultBehavior) : base(query) { if (scalarResultBehavior == null) { throw new ArgumentNullException("scalarResultBehavior"); } _scalarResultBehavior = scalarResultBehavior; }
/// <summary> /// Creates a new LinqQueryRequest, with the given N1QL query. /// </summary> /// <param name="scalarResultBehavior">Behaviors related to extracting results for scalar queries.</param> public LinqQueryOptions(ScalarResultBehavior scalarResultBehavior) { _scalarResultBehavior = scalarResultBehavior ?? throw new ArgumentNullException("scalarResultBehavior"); }