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


C# CouchbaseClient.GetView方法代码示例

本文整理汇总了C#中CouchbaseClient.GetView方法的典型用法代码示例。如果您正苦于以下问题:C# CouchbaseClient.GetView方法的具体用法?C# CouchbaseClient.GetView怎么用?C# CouchbaseClient.GetView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CouchbaseClient的用法示例。


在下文中一共展示了CouchbaseClient.GetView方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public override void Run()
        {
            var config = new CouchbaseClientConfiguration();
            config.Urls.Add(new Uri("http://localhost:8091/pools/"));
            config.Bucket = "beer-sample";

            var client = new CouchbaseClient(config);

            Console.WriteLine("Breweries by_name, limited to 10 records");
            var view = client.GetView("breweries", "by_name").Limit(10);

            Console.WriteLine("Breweries by_name, output the keys");
            view = client.GetView("breweries", "by_name").Limit(10);
            foreach (var item in view)
            {
                Console.WriteLine("Key: " + item.ViewKey.First());
            }

            Console.WriteLine("Breweries by_name, query by key range (y or Y)");
            view = client.GetView("breweries", "by_name").StartKey("y").EndKey("z");
            foreach (var item in view)
            {
                Console.WriteLine("Key: " + item.ViewKey.First());
            }

            Console.WriteLine("Breweries by_name, output the keys (y only)");
            view = client.GetView("breweries", "by_name").StartKey("y").EndKey("Y");
            foreach (var item in view)
            {
                Console.WriteLine("Key: " + item.ViewKey.First());
            }
        }
开发者ID:ebay-snarwal,项目名称:DeveloperDay,代码行数:32,代码来源:08_Views.cs

示例2: Main

        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            //Manually configure CouchbaseClient
            //May also use app/web.config section
            var config = new CouchbaseClientConfiguration();
            config.Bucket = "default";
            config.BucketPassword = "";
            config.Urls.Add(new Uri("http://10.0.0.79:8091/pools"));
            config.DesignDocumentNameTransformer = new ProductionModeNameTransformer();
            config.HttpClientFactory = new HammockHttpClientFactory();

            //Quick test of Store/Get operations
            var client = new CouchbaseClient(config);
            var result = client.Store(StoreMode.Set, "foo", "bar");

            Debug.Assert(result, "Store failed");
            Console.WriteLine("Item saved successfully");

            var value = client.Get<string>("foo");
            Debug.Assert(value == "bar", "Get failed");
            Console.WriteLine("Item retrieved succesfully");

            processJson(client);

            Console.WriteLine("\r\n\r\n***  SAMPLE VIEWS MUST BE CREATED - SEE SampleViews.js in Data directory ***");

            Console.WriteLine("\r\n\r\nRequesting view all_breweries");
            var allBreweries = client.GetView<Brewery>("breweries", "all_breweries");
            foreach (var item in allBreweries)
            {
                Console.WriteLine(item.Name);
            }

            Console.WriteLine("\r\n\r\nRequesting view beers_by_name");
            var beersByName = client.GetView<Beer>("beers", "beers_by_name").StartKey("T");
            foreach (var item in beersByName)
            {
                Console.WriteLine(item.Name);
            }

            Console.WriteLine("\r\n\r\nRequesting view beers_by_name_and_abv");
            var beersByNameAndABV = client.GetView<Beer>("beers", "beers_by_name_and_abv")
                                       .StartKey(new object[] { "T", 6 });
            foreach (var item in beersByNameAndABV)
            {
                Console.WriteLine(item.Name);
            }
        }
开发者ID:e-travel,项目名称:couchbase-net-client,代码行数:50,代码来源:Program.cs

示例3: View_Operations_Succeed_When_Initialize_Connection_Is_True

 public void View_Operations_Succeed_When_Initialize_Connection_Is_True()
 {
     var config = ConfigSectionUtils.GetConfigSection<CouchbaseClientSection>("httpclient-config-initconn");
     var client = new CouchbaseClient(config);
     var view = client.GetView<City>("cities", "by_name", true).Stale(StaleMode.False);
     viewPass(view);
 }
开发者ID:eugentorica,项目名称:couchbase-net-client,代码行数:7,代码来源:HttpClientConfigTests.cs

示例4: AAAA

        static void AAAA()
        {
            //ITranscoder tr = new JsonTranscoder();

            //Dump(tr.Serialize("a").Data);
            //Dump(tr.Serialize(null).Data);
            //Dump(tr.Serialize(1.0f).Data);
            //Dump(tr.Serialize(2.4d).Data);
            //Dump(tr.Serialize(08976543).Data);
            //Dump(tr.Serialize(new { A = "a", B = 2, C = true, D = new[] { 1, 2, 3, 4 } }).Data);

            //var o = tr.Deserialize(tr.Serialize(new Tmp { A = "a" }));

            //Console.WriteLine(tr.Deserialize(tr.Serialize((Single)1)).GetType());
            //Console.WriteLine(tr.Deserialize(tr.Serialize((Double)1)).GetType());

            var mbc = new CouchbaseClientConfiguration();
            mbc.Urls.Add(new Uri("http://192.168.47.128:8091/pools/default"));

            var c = new CouchbaseClient(mbc);

            //	for (var i = 0; i < 10; i++) c.Store(StoreMode.Set, "json_" + i, i + 100);
            //for (var i = 0; i < 10; i++) c.Store(StoreMode.Set, "binary_" + i, i + 100);

            //for (var i = 0; i < 1000; i++)
            //    c.Store(StoreMode.Set, "key_" + i, i);

            var r = c.GetView("test", "all").Limit(20);
            var tmp = c.Get(r);

            //Console.WriteLine(r.Count);
        }
开发者ID:vitaly-rudenya,项目名称:couchbase-net-client,代码行数:32,代码来源:Program.cs

示例5: When_Bucket_Is_Authenticated_And_Bad_Credentials_Are_Provided_Exception_Is_Thrown

        public void When_Bucket_Is_Authenticated_And_Bad_Credentials_Are_Provided_Exception_Is_Thrown()
        {
            Client = GetClient(_bucketName, "bad_credentials");
            var view = Client.GetView("cities", "by_name");

            var row = view.First();
            Assert.IsNotNull(row);
        }
开发者ID:JebteK,项目名称:couchbase-net-client,代码行数:8,代码来源:CouchbaseAuthenticatedViewTests.cs

示例6: When_Bucket_Is_Authenticated_And_No_Credentials_Are_Provided_Exception_Is_Thrown

        public void When_Bucket_Is_Authenticated_And_No_Credentials_Are_Provided_Exception_Is_Thrown()
        {
            Client = GetClient(_bucketName, "");
            var view = Client.GetView("cities", "by_name");

            var row = view.First();

            //Test will end on previous line
            Assert.IsNotNull(row);
        }
开发者ID:JebteK,项目名称:couchbase-net-client,代码行数:10,代码来源:CouchbaseAuthenticatedViewTests.cs

示例7: GetBreweryList

        /// <summary>
        /// Get all breweries from view
        /// </summary>
        /// <returns></returns>
        public IList<Brewery> GetBreweryList()
        {
            List<Brewery> resultSet = new List<Brewery>();
            Brewery brewery = null;

            using (CouchbaseClient client = new CouchbaseClient())
            {
                var view = client.GetView("beer", "brewery");

                foreach (var row in view)
                {
                    brewery = client.GetJson<Brewery>(row.ItemId);
                    resultSet.Add(brewery);
                }
            }

            return resultSet;
        }
开发者ID:volkanx,项目名称:BeerExplorer,代码行数:22,代码来源:BreweryRepository.cs

示例8: GetBeerByBrewery

        /// <summary>
        /// Get a list of beers brewed by a specific brewery
        /// </summary>
        /// <param name="breweryName"></param>
        /// <returns></returns>
        public IList<Beer> GetBeerByBrewery(string breweryId)
        {
            List<Beer> resultSet = new List<Beer>();
            Beer beer = null;

            using (CouchbaseClient client = new CouchbaseClient())
            {
                var view = client.GetView("beer", "by_brewery_id")
                                 .StartKey<string>(breweryId)
                                 .EndKey<string>(breweryId);

                foreach (var row in view)
                {
                    beer = client.GetJson<Beer>(row.ItemId);
                    resultSet.Add(beer);
                }
            }

            return resultSet;
        }
开发者ID:volkanx,项目名称:BeerExplorer,代码行数:25,代码来源:BeerRepository.cs

示例9: When_Bucket_Is_Authenticated_View_Returns_Results

        public void When_Bucket_Is_Authenticated_View_Returns_Results()
        {
            Client = GetClient(_bucketName, _bucketPassword);
            var view = Client.GetView("cities", "by_name");

            //Whether or view has data is regardless, what matters is that a authenticated call returned succesfully
            Assert.IsNotNull(view);
        }
开发者ID:JebteK,项目名称:couchbase-net-client,代码行数:8,代码来源:CouchbaseAuthenticatedViewTests.cs

示例10: Main

        static void Main(string[] args)
        {
            Options options = new Options();
            CommandLineParserSettings parserSettings = new CommandLineParserSettings();
            parserSettings.CaseSensitive = true;
            CommandLineParser parser = new CommandLineParser(parserSettings);

            if (!parser.ParseArguments(args, options, Console.Error))
            {
                return;
            }

            var config = new CouchbaseClientConfiguration();
            config.Bucket = options.Bucket;
            var url = "http://";
            if (!options.Hostname.Contains(":"))
            {
                options.Hostname += ":8091";
            }
            url += options.Hostname + "/pools";
            config.Urls.Add(new Uri(url));

            Console.Error.WriteLine("URL: " + url + ", Bucket: " + config.Bucket);
            Console.Error.WriteLine("Design: " + options.Design + ", View: " + options.View);

            CouchbaseClient cli = new CouchbaseClient(config);
            var res = cli.ExecuteStore(Enyim.Caching.Memcached.StoreMode.Set, "foo", "bar");
            Console.WriteLine("Store result ? {0}", res.Success);

            var view = cli.GetView(options.Design, options.View);
            if (options.Group)
            {
                view.Group(options.Group);
            }
            if (options.GroupLevel > 0)
            {
                view.GroupAt(options.GroupLevel);
            }

            if (options.Range != null)
            {
                if (options.Range.Count > 2)
                {
                    Console.Error.WriteLine("Too many keys in range (use -R for compount keys)");
                    return;
                }
                if (!String.IsNullOrEmpty(options.Range[0]))
                {
                    view.StartKey(options.Range[0]);
                }
                if (!String.IsNullOrEmpty(options.Range[1]))
                {
                    view.EndKey(options.Range[1]);
                }
            }
            else if (options.CompoundRanges != null)
            {
                IList<string> sk = null, ek = null;

                int firstIx = options.CompoundRanges.IndexOf(":");
                if (firstIx == -1)
                {
                    Console.Error.WriteLine("Malformed compound range");
                    return;
                }
                if (firstIx == 0)
                {
                    ek = options.CompoundRanges.Skip(1).ToList();
                }
                else if (firstIx == options.CompoundRanges.Count - 1)
                {
                    sk = options.CompoundRanges.Take(
                        options.CompoundRanges.Count - 1).ToList();
                }
                else
                {
                    sk = options.CompoundRanges.Take(firstIx).ToList();
                    ek = options.CompoundRanges.Skip(firstIx + 1).ToList();
                }

                if (sk != null)
                {
                    Console.Error.WriteLine("Using start key " +
                        new JavaScriptSerializer().Serialize(sk));
                    view.StartKey(sk);
                }
                if (ek != null)
                {
                    if (ek[0].StartsWith("+"))
                    {
                        ek[0] = new String(ek[0].Skip(1).ToArray());
                        view.WithInclusiveEnd(true);
                    }

                    Console.Error.WriteLine("Using end key " +
                        new JavaScriptSerializer().Serialize(ek));

                    view.EndKey(ek);
                }
            }
//.........这里部分代码省略.........
开发者ID:mnunberg,项目名称:cbc-net,代码行数:101,代码来源:Program.cs


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