本文整理汇总了C#中Article.SaveAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Article.SaveAsync方法的具体用法?C# Article.SaveAsync怎么用?C# Article.SaveAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article.SaveAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveMultivaluedAsyncTest
public async Task SaveMultivaluedAsyncTest()
{
var array = new[] { 1, 3, 4, 5, 6, 7 };
var obj = new Article("object");
obj.SetList<int>("multifield", array);
await obj.SaveAsync();
var saved = await Articles.GetAsync("object", obj.Id);
var array2 = saved.GetList<int>("multifield");
Assert.IsTrue(array.Intersect(array2).Count() == array.Length);
}
示例2: CreateArticleAsyncTest
public async Task CreateArticleAsyncTest()
{
dynamic obj = new Article("object");
obj.intfield = 1;
obj.decimalfield = 22m / 7m;
await obj.SaveAsync();
var saved = obj as Article;
Assert.IsNotNull(saved);
Assert.IsTrue(string.IsNullOrWhiteSpace(saved.Id) == false);
Console.WriteLine("Created article with id {0}.", saved.Id);
}
示例3: MultiValueArticleTest
public async Task MultiValueArticleTest()
{
var obj = new Article("object");
obj.SetList<string>("multifield", new[] { "1", "2", "3", "4" });
await obj.SaveAsync();
var read = await Articles.GetAsync("object", obj.Id);
var value = read.GetList<string>("multifield");
var strList = read.GetList<string>("multifield");
var intList = read.GetList<int>("multifield");
}
示例4: FindAndDisplayAllArticlesTest
public async Task FindAndDisplayAllArticlesTest()
{
var waitHandle = new ManualResetEvent(false);
// Create the article
dynamic obj = new Article("object");
obj.stringfield = Unique.String;
await obj.SaveAsync();
var saved = obj as Article;
Console.WriteLine("Created articled with id {0}", saved.Id);
var index = 1;
// Search
var articles = await Article.FindAllAsync("object", Query.None, Article.AllFields, 1, 100);
do
{
articles.ForEach(a => Console.WriteLine("{0}) {1}", index++, a.Id));
Console.WriteLine("page:{0} pageSize:{1} total: {2}", articles.PageNumber, articles.PageSize, articles.TotalRecords);
if (articles.IsLastPage == false)
articles = await articles.NextPageAsync();
else
break;
} while (true);
Console.WriteLine("Finished.");
}