本文整理汇总了C#中IDocumentStore.LightweightSession方法的典型用法代码示例。如果您正苦于以下问题:C# IDocumentStore.LightweightSession方法的具体用法?C# IDocumentStore.LightweightSession怎么用?C# IDocumentStore.LightweightSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDocumentStore
的用法示例。
在下文中一共展示了IDocumentStore.LightweightSession方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: lightweight_document_session
// SAMPLE: lightweight_document_session_uow
public void lightweight_document_session(IDocumentStore store)
{
using (var session = store.LightweightSession())
{
var user = new User {FirstName = "Jeremy", LastName = "Miller"};
// Manually adding the new user to the session
session.Store(user);
var existing = session.Query<User>().Single(x => x.FirstName == "Max");
existing.Internal = false;
// Manually marking an existing user as changed
session.Store(existing);
// Marking another existing User document as deleted
session.Delete<User>(Guid.NewGuid());
// Persisting the changes to the database
session.SaveChanges();
}
}
示例2: RecordCommit
/*
public void RecordCommit(GitHubCommit commit, GitHubCommitStats stats)
{
var @event = new Commit
{
Sha = commit.Sha,
Message = commit.Commit.Message,
Timestamp = commit.Commit.Author.Date,
Additions = stats.Additions,
Deletions = stats.Deletions,
UserName = commit.Author?.Login
};
_events.Add(@event);
}
*/
public async Task PublishEvents(IDocumentStore store, int pause, bool createEventGaps)
{
var events = Events.OrderBy(x => x.Timestamp).ToList();
var started = events.OfType<ProjectStarted>().Single();
events.Remove(started);
events.Insert(0, started);
var index = 0;
var page = events.Skip(index).Take(10).ToArray();
while (page.Length > 0)
{
using (var session = store.LightweightSession())
{
session.Events.Append(Id, page);
if (createEventGaps)
{
for (int i = 0; i < 200; i++)
{
session.Events.Append(Id, new PlaceHolder());
}
}
await session.SaveChangesAsync().ConfigureAwait(false);
}
index += 10;
page = events.Skip(index).Take(10).ToArray();
Thread.Sleep(pause);
}
}