本文整理汇总了C#中CouchbaseClient.GetJson方法的典型用法代码示例。如果您正苦于以下问题:C# CouchbaseClient.GetJson方法的具体用法?C# CouchbaseClient.GetJson怎么用?C# CouchbaseClient.GetJson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CouchbaseClient
的用法示例。
在下文中一共展示了CouchbaseClient.GetJson方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBeer
/// <summary>
/// Retrieve the beer object by name
/// </summary>
/// <param name="beerName"></param>
/// <returns></returns>
public Beer GetBeer(string beerName)
{
using (CouchbaseClient client = new CouchbaseClient())
{
Beer beer = client.GetJson<Beer>(beerName);
return beer;
}
}
示例2: GetBrewery
/// <summary>
/// Retrieve the brewery object by key
/// </summary>
/// <param name="breweryId"></param>
/// <returns></returns>
public Brewery GetBrewery(string breweryId)
{
using (CouchbaseClient client = new CouchbaseClient())
{
Brewery brewery = client.GetJson<Brewery>(breweryId);
return brewery;
}
}
示例3: Run
public override void Run()
{
var config = new CouchbaseClientConfiguration();
config.Urls.Add(new Uri("http://localhost:8091/pools/"));
config.Bucket = "default";
var client = new CouchbaseClient(config);
//Store JSON
client.StoreJson(StoreMode.Set, "CT_Hartford", new City { Name = "Hartford", State = "CT" });
//Get City instance back from JSON
var city = client.GetJson<City>("CT_Hartford");
Console.WriteLine(city.Name);
client.Remove("CT_Hartford");
}
示例4: 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;
}
示例5: 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;
}