本文整理汇总了C#中CouchbaseClient.StoreJson方法的典型用法代码示例。如果您正苦于以下问题:C# CouchbaseClient.StoreJson方法的具体用法?C# CouchbaseClient.StoreJson怎么用?C# CouchbaseClient.StoreJson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CouchbaseClient
的用法示例。
在下文中一共展示了CouchbaseClient.StoreJson方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertBeer
/// <summary>
/// Create a new beer object
/// </summary>
/// <param name="beer"></param>
/// <returns></returns>
public bool InsertBeer(Beer beer)
{
bool result = false;
using (CouchbaseClient client = new CouchbaseClient())
{
result = client.StoreJson(StoreMode.Add, beer.Name, beer);
}
return result;
}
示例2: InsertOrUpdateBrewery
/// <summary>
/// Add new or update existing beer object
/// </summary>
/// <param name="beer"></param>
/// <returns></returns>
public bool InsertOrUpdateBrewery(Brewery brewery)
{
bool result = false;
using (CouchbaseClient client = new CouchbaseClient())
{
result = client.StoreJson(StoreMode.Replace, brewery.Name, brewery);
}
return result;
}
示例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");
}