本文整理汇总了C#中IDocumentStore.WaitForStaleIndexesToComplete方法的典型用法代码示例。如果您正苦于以下问题:C# IDocumentStore.WaitForStaleIndexesToComplete方法的具体用法?C# IDocumentStore.WaitForStaleIndexesToComplete怎么用?C# IDocumentStore.WaitForStaleIndexesToComplete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDocumentStore
的用法示例。
在下文中一共展示了IDocumentStore.WaitForStaleIndexesToComplete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSeedData
public static void CreateSeedData(IDocumentStore documentStore)
{
Condition.Requires(documentStore).IsNotNull();
using (IDocumentSession documentSession = documentStore.OpenSession())
{
// First, check to make sure we don't have any data.
var user = documentSession.Load<User>(1);
if (user != null)
{
// ooOooo! we have a user, so it's assumed we actually have some seeded data.
return;
}
// We have no users, so it's assumed we therefore have no data at all.
// So lets fake some up :)
// Users.
ICollection<User> users = FakeUsers.CreateFakeUsers(50);
StoreFakeEntities(users, documentSession);
// Questions.
ICollection<Question> questions = FakeQuestions.CreateFakeQuestions(users.Select(x => x.Id).ToList());
StoreFakeEntities(questions, documentSession);
documentSession.SaveChanges();
// Make sure all our indexes are not stale.
documentStore.WaitForStaleIndexesToComplete();
}
}
示例2: CreateSeedData
public static void CreateSeedData(IDocumentStore documentStore)
{
Condition.Requires(documentStore).IsNotNull();
using (IDocumentSession documentSession = documentStore.OpenSession())
{
// Users.
ICollection<User> users = FakeUsers.CreateFakeUsers(50);
StoreFakeEntities(users, documentSession);
// Questions.
ICollection<Question> questions = FakeQuestions.CreateFakeQuestions(users.Select(x => x.Id).ToList());
StoreFakeEntities(questions, documentSession);
documentSession.SaveChanges();
// Make sure all our indexes are not stale.
documentStore.WaitForStaleIndexesToComplete();
}
}
示例3: CreateSeedDataAsync
private static async Task CreateSeedDataAsync(IEnumerable<IEnumerable> seedData, IDocumentStore documentStore)
{
if (documentStore == null)
{
throw new ArgumentNullException("documentStore");
}
if (seedData == null)
{
throw new ArgumentNullException("seedData");
}
using (var asyncDocumentSession = documentStore.OpenAsyncSession())
{
// First, check to make sure we don't have any data.
if (documentStore.DatabaseCommands.GetStatistics().CountOfDocuments > 0)
{
// We have documents, so nothing to worry about :)
return;
}
// Store each collection of fake seeded data.
Trace.TraceInformation("Seeding Data :-");
foreach (var collection in seedData)
{
var count = 0;
var entityName = "Unknown";
foreach (var entity in collection)
{
count++;
if (count <= 1)
{
entityName = entity.GetType().ToString();
}
await asyncDocumentSession.StoreAsync(entity);
}
Trace.TraceInformation(" --- {0} {1}", count, entityName);
}
Trace.TraceInformation(" Done!");
// Commit this transaction.
await asyncDocumentSession.SaveChangesAsync();
// Make sure all our indexes are not stale.
documentStore.WaitForStaleIndexesToComplete();
}
}
示例4: CreateSeedData
private static void CreateSeedData(IEnumerable<IEnumerable> seedData, IDocumentStore documentStore)
{
if (documentStore == null)
{
throw new ArgumentNullException("documentStore");
}
if (seedData == null)
{
throw new ArgumentNullException("seedData");
}
using (IDocumentSession documentSession = documentStore.OpenSession())
{
// First, check to make sure we don't have any data.
if (documentSession.Advanced.DocumentStore.DatabaseCommands.GetStatistics().CountOfDocuments > 0)
{
// We have documents, so nothing to worry about :)
return;
}
// Store each collection of fake seeded data.
Debug.WriteLine("Seeding Data :-");
foreach (IEnumerable collection in seedData)
{
int count = 0;
string entityName = "Unknown";
foreach (object entity in collection)
{
count++;
if (count <= 1)
{
entityName = entity.GetType().ToString();
}
documentSession.Store(entity);
}
Debug.WriteLine(" --- {0} {1}", count, entityName);
}
Debug.WriteLine(" Done!");
// Commit this transaction.
documentSession.SaveChanges();
// Make sure all our indexes are not stale.
documentStore.WaitForStaleIndexesToComplete();
}
}