本文整理汇总了C#中Store.InitializeAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Store.InitializeAsync方法的具体用法?C# Store.InitializeAsync怎么用?C# Store.InitializeAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Store
的用法示例。
在下文中一共展示了Store.InitializeAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static void Main(string[] args)
{
var configuration = new Configuration
{
ConnectionFactory = new DbConnectionFactory<SqliteConnection>(@"Data Source=:memory:", true),
DocumentStorageFactory = new InMemoryDocumentStorageFactory()
};
var store = new Store(configuration);
store.InitializeAsync().Wait();
using (var session = store.CreateSession())
{
session.ExecuteMigration(x => x
.CreateReduceIndexTable(nameof(ArticleByWord), table => table
.Column<int>("Count")
.Column<string>("Word")
)
);
}
// register available indexes
store.RegisterIndexes<ArticleIndexProvider>();
// creating articles
using (var session = store.CreateSession())
{
session.Save(new Article { Content = "This is a white fox" });
session.Save(new Article { Content = "This is a brown cat" });
session.Save(new Article { Content = "This is a pink elephant" });
session.Save(new Article { Content = "This is a white tiger" });
}
using (var session = store.CreateSession())
{
Console.WriteLine("Simple term: 'white'");
var simple = session.QueryAsync<Article, ArticleByWord>().Where(a => a.Word == "white").List().Result;
foreach (var article in simple)
{
Console.WriteLine(article.Content);
}
Console.WriteLine("Boolean query: 'white or fox or pink'");
var boolQuery = session.QueryAsync<Article, ArticleByWord>().Where(a => a.Word.IsIn(new[] { "white", "fox", "pink" })).List().Result;
foreach (var article in boolQuery)
{
Console.WriteLine(article.Content);
}
}
}