当前位置: 首页>>代码示例>>C#>>正文


C# N1QL.QueryRequest类代码示例

本文整理汇总了C#中Couchbase.N1QL.QueryRequest的典型用法代码示例。如果您正苦于以下问题:C# QueryRequest类的具体用法?C# QueryRequest怎么用?C# QueryRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


QueryRequest类属于Couchbase.N1QL命名空间,在下文中一共展示了QueryRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindAll

        public object FindAll(string search, string token)
        {
            if (search.Length == 3)
            {
                // LAX
                var query =
                    new QueryRequest("SELECT airportname FROM `" + CouchbaseConfigHelper.Instance.Bucket + "` WHERE faa=$1")
                    .AddPositionalParameter(search.ToUpper());

                return CouchbaseStorageHelper.Instance.ExecuteQuery(query).Rows;
            }
            else if (search.Length == 4)
            {
                // KLAX
                var query =
                    new QueryRequest("SELECT airportname FROM `" + CouchbaseConfigHelper.Instance.Bucket + "` WHERE icao = '$1'")
                    .AddPositionalParameter(search.ToUpper());

                return CouchbaseStorageHelper.Instance.ExecuteQuery(query).Rows;
            }
            else
            {
                // Los Angeles
                var query =
                    new QueryRequest("SELECT airportname FROM `" + CouchbaseConfigHelper.Instance.Bucket + "` WHERE airportname LIKE $1")
                    .AddPositionalParameter("%" + search + "%");

                return CouchbaseStorageHelper.Instance.ExecuteQuery(query).Rows;
            }
        }
开发者ID:boblarson57,项目名称:try-cb-dotnet,代码行数:30,代码来源:AirportController.cs

示例2: ReplayMessagesAsync

        public override Task ReplayMessagesAsync(string persistenceId, long fromSequenceNr, long toSequenceNr, long max, Action<IPersistentRepresentation> replayCallback)
        {
            // Limit(0) doesn't work...
            if (max == 0)
                return Task.Run(() => {});

            // Limit allows only integer
            var maxValue = max >= int.MaxValue ? int.MaxValue : (int)max;
            var sender = Context.Sender;

            String N1QLQueryString = "SELECT `" + _CBBucket.Name + "`.* FROM `" + _CBBucket.Name + "` WHERE PersistenceId = $PersistenceId AND SequenceNr >= $FromSequenceNr  AND SequenceNr <= $ToSequenceNr ORDER BY SequenceNr ASC LIMIT $Maximum";

            IQueryRequest N1QLQueryRequest = new QueryRequest()
            .Statement(N1QLQueryString)
            .AddNamedParameter("PersistenceId", persistenceId)
            .AddNamedParameter("FromSequenceNr", fromSequenceNr)
            .AddNamedParameter("ToSequenceNr", toSequenceNr)
            .AddNamedParameter("Maximum", maxValue)
            .AdHoc(false);

            Couchbase.N1QL.IQueryResult<JournalEntry> result = _CBBucket.Query<JournalEntry>(N1QLQueryRequest);


            return result.Rows.ForEachAsync<JournalEntry>(je => replayCallback(ToPersistanceRepresentation(je, sender)));
        }
开发者ID:akkadotnet,项目名称:Akka.Persistence.CouchBase,代码行数:25,代码来源:CouchBaseDbJournal.cs

示例3: LoadAsync

        protected override Task<SelectedSnapshot> LoadAsync(string persistenceId, SnapshotSelectionCriteria criteria)
        {

            // Create a Query with dynamic parameters
            string N1QLQueryString = "select `" + _CBBucket.Name + "`.* from `" + _CBBucket.Name + "` where DocumentType = 'SnapshotEntry' AND PersistenceId = $PersistenceId ";

            IQueryRequest N1QLQueryRequest = new QueryRequest()
                    .AddNamedParameter("PersistenceId", persistenceId);

            string N1QLQueryOrderByClauseString = "ORDER BY SequenceNr DESC";
            
            if (criteria.MaxSequenceNr > 0 && criteria.MaxSequenceNr < long.MaxValue)
            {
                N1QLQueryString += "AND SequenceNr <= $limit ";
                N1QLQueryOrderByClauseString = "ORDER BY SequenceNr DESC,";
                N1QLQueryRequest.AddNamedParameter("limit",criteria.MaxSequenceNr);
            }

            if (criteria.MaxTimeStamp != DateTime.MinValue && criteria.MaxTimeStamp != DateTime.MaxValue)
            {
                N1QLQueryString += " AND Timestamp <= $timelimit ";
                N1QLQueryOrderByClauseString = "ORDER BY Timestamp DESC,";
                N1QLQueryRequest.AddNamedParameter("timelimit", criteria.MaxTimeStamp.Ticks.ToString());
            }

            N1QLQueryString += N1QLQueryOrderByClauseString.TrimEnd(',') + " LIMIT 1"; 

            N1QLQueryRequest.Statement(N1QLQueryString).AdHoc(false);

            return taskLoadAsync(N1QLQueryRequest);
                

        }
开发者ID:akkadotnet,项目名称:Akka.Persistence.CouchBase,代码行数:33,代码来源:CouchBaseDbSnapshotStore.cs

示例4: Test_Statement

        public void Test_Statement()
        {
            var query = new QueryRequest().
                BaseUri(new Uri(string.Format("http://{0}:8093/query", _server))).
                Statement("SELECT * FROM default");

            var values = query.GetFormValues();
            Assert.AreEqual("SELECT * FROM default", values["statement"]);
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:9,代码来源:QueryRequestTests.cs

示例5: Test_Query_HelloWorld

        public void Test_Query_HelloWorld()
        {
            var client = GetQueryClient();
            var uri = new Uri(string.Format("http://{0}:8093/query", _server));
            var query = new QueryRequest("SELECT 'Hello World' AS Greeting").BaseUri(uri);

            var result = client.Query<dynamic>(query);
            Assert.IsNotNull(result);
            Assert.AreEqual("Hello World", result.Rows.First().Greeting.ToString());
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:10,代码来源:QueryClientTests.cs

示例6: Test_Statement

        public void Test_Statement()
        {
            var query = new QueryRequest().
                BaseUri(new Uri(string.Format("http://{0}:8093/query", _server))).
                Statement("SELECT * FROM default");

            var uri = query.GetRequestUri();
            Assert.IsTrue(uri.ToString().Contains(":8093/query?statement=SELECT * FROM default"));
            Console.WriteLine(uri);
        }
开发者ID:TDevs,项目名称:couchbase-net-client,代码行数:10,代码来源:QueryRequestTests.cs

示例7: Test_Positional_Parameters

        public void Test_Positional_Parameters()
        {
            var query = new QueryRequest().
                BaseUri(new Uri(string.Format("http://{0}:8093/query", _server))).
                Statement("SELECT * FROM default WHERE type=$1").
                AddPositionalParameter("dog");

            var values = query.GetFormValues();
            Assert.AreEqual("SELECT * FROM default WHERE type=$1", values["statement"]);
            Assert.AreEqual(new[] {"dog"}, values["args"]);
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:11,代码来源:QueryRequestTests.cs

示例8: Test_Statement_ClientContextId_Pretty

        public void Test_Statement_ClientContextId_Pretty()
        {
            var query = new QueryRequest().
                BaseUri(new Uri(string.Format("http://{0}:8093/query", _server))).
                Statement("SELECT * FROM default").
                ClientContextId("somecontextlessthanorequalto64chars").
                Pretty(true);

            var values = query.GetFormValues();
            Assert.AreEqual(true, values["pretty"]);
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:11,代码来源:QueryRequestTests.cs

示例9: Test_Statement_ClientContextId

        public void Test_Statement_ClientContextId()
        {
            var query = new QueryRequest().
                BaseUri(new Uri(string.Format("http://{0}:8093/query", _server))).
                Statement("SELECT * FROM default").
                ClientContextId("somecontextlessthanorequalto64chars");

            var values = query.GetFormValues();
            string contextid = values["client_context_id"].ToString().Split(new String[] {"::"}, System.StringSplitOptions.None)[0];
            Assert.AreEqual("somecontextlessthanorequalto64chars", contextid);
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:11,代码来源:QueryRequestTests.cs

示例10: Test_Query_HelloWorld

        public void Test_Query_HelloWorld()
        {
            var config = new ClientConfiguration();
            var client = new QueryClient(new HttpClient(), new JsonDataMapper(config), new BucketConfig(), config);
            var uri = new Uri(string.Format("http://{0}:8093/query", _server));
            var query = new QueryRequest("SELECT 'Hello World' AS Greeting").BaseUri(uri);

            var result = client.Query<dynamic>(query);
            Assert.IsNotNull(result);
            Assert.AreEqual("Hello World", result.Rows.First().Greeting.ToString());
        }
开发者ID:orangeloop,项目名称:couchbase-net-client,代码行数:11,代码来源:QueryClientTests.cs

示例11: Test_Statement

        public void Test_Statement()
        {
            var query = new QueryRequest().
                BaseUri(new Uri(string.Format("http://{0}:8093/query", _server))).
                Statement("SELECT * FROM default");

            var json = query.GetFormValuesAsJson();
            var expected = "{\"statement\":\"SELECT * FROM default\",\"timeout\":\"75000ms\"}";
            Console.WriteLine(json);
            Assert.AreEqual(expected, json);
        }
开发者ID:orangeloop,项目名称:couchbase-net-client,代码行数:11,代码来源:QueryRequestTests.cs

示例12: Test_N1QL_Query

        public void Test_N1QL_Query()
        {
            using (var bucket = _cluster.OpenBucket())
            {
                var query = new QueryRequest("SELECT * FROM `beer-sample` LIMIT 10");

                var result = bucket.Query<dynamic>(query);
                Assert.IsTrue(result.Success);
                Assert.AreEqual(10, result.Rows.Count);
            }
        }
开发者ID:hyah,项目名称:couchbase-net-client,代码行数:11,代码来源:CouchbaseBucket_N1QL_Tests.cs

示例13: Test_Statement_ClientContextId

        public void Test_Statement_ClientContextId()
        {
            var query = new QueryRequest().
                BaseUri(new Uri(string.Format("http://{0}:8093/query", _server))).
                Statement("SELECT * FROM default").
                ClientContextId("somecontextlessthanorequalto64chars");

            var uri = query.GetRequestUri();
            Console.WriteLine(uri);
            Assert.IsTrue(uri.ToString().Contains(":8093/query?statement=SELECT * FROM default&client_context_id=somecontextlessthanorequalto64chars"));
        }
开发者ID:TDevs,项目名称:couchbase-net-client,代码行数:11,代码来源:QueryRequestTests.cs

示例14: Test_Positional_Parameters

        public void Test_Positional_Parameters()
        {
            var query = new QueryRequest().
                BaseUri(new Uri(string.Format("http://{0}:8093/query", _server))).
                Statement("SELECT * FROM default WHERE type=$1").
                AddPositionalParameter("dog");

            var uri = query.GetRequestUri();
            Console.WriteLine(uri);
            Assert.IsTrue(uri.ToString().Contains(":8093/query?statement=SELECT * FROM default WHERE type=$1&args=[\"dog\"]"));
        }
开发者ID:TDevs,项目名称:couchbase-net-client,代码行数:11,代码来源:QueryRequestTests.cs

示例15: Test_Positional_Parameters

        public void Test_Positional_Parameters()
        {
            var query = new QueryRequest().
                BaseUri(new Uri(string.Format("http://{0}:8093/query", _server))).
                Statement("SELECT * FROM default WHERE type=$1").
                AddPositionalParameter("dog");

            var json = query.GetFormValuesAsJson();
            var expected = "{\"statement\":\"SELECT * FROM default WHERE type=$1\",\"timeout\":\"75000ms\",\"args\":[\"dog\"]}";
            Console.WriteLine(json);
            Assert.AreEqual(expected, json);
        }
开发者ID:orangeloop,项目名称:couchbase-net-client,代码行数:12,代码来源:QueryRequestTests.cs


注:本文中的Couchbase.N1QL.QueryRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。