本文整理汇总了C#中IAsyncDocumentSession.SaveChangesAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IAsyncDocumentSession.SaveChangesAsync方法的具体用法?C# IAsyncDocumentSession.SaveChangesAsync怎么用?C# IAsyncDocumentSession.SaveChangesAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAsyncDocumentSession
的用法示例。
在下文中一共展示了IAsyncDocumentSession.SaveChangesAsync方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteAsync
public async override Task<HttpResponseMessage> ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken) {
using (Session = Store.OpenAsyncSession()) {
var result = await base.ExecuteAsync(controllerContext, cancellationToken);
await Session.SaveChangesAsync();
return result;
}
}
示例2: SaveEntities
protected static async Task SaveEntities(IEnumerable<IEntity> entities, IAsyncDocumentSession session)
{
foreach (var entity in entities)
{
await session.StoreAsync(entity);
}
await session.SaveChangesAsync();
}
示例3: EnsureSubscriptionsExists
private async Task EnsureSubscriptionsExists(IAsyncDocumentSession session)
{
var subscription = await session.LoadAsync<Subscription>(Subscription.Id);
if (subscription == null)
{
subscription = new Subscription();
await session.StoreAsync(subscription);
await session.SaveChangesAsync();
}
}
示例4: Index
public async Task<ActionResult> Index(IAsyncDocumentSession asyncSession)
{
// Remove when MVC 4 is released (http://forums.asp.net/p/1778103/4880898.aspx/1?Re+Using+an+Async+Action+to+Run+Synchronous+Code)
await Task.Yield();
var mike = (await asyncSession.Query<User>().Take(1).ToListAsync()).FirstOrDefault();
if (mike == null)
{
mike = new User {FirstName = "Mike", LastName = "Noonan"};
asyncSession.Store(mike);
await asyncSession.SaveChangesAsync();
}
if (mike.F1AccessToken == null || mike.PCOAccessToken == null)
{
return RedirectToAction("Authenticate", "F1Auth");
}
return View();
}
示例5: CreateDefaultData
private static void CreateDefaultData(IAsyncDocumentSession session)
{
var role = new ApplicationRole("Admin");
session.StoreAsync(role);
var hasher = new PasswordHasher();
var passwordHash = hasher.HashPassword("admin");
var superUser = new ApplicationUser("SuperAdmin")
{
Email = "[email protected]",
FirstName = "Super",
LastName = "Admin",
UserName = "superadmin",
PasswordHash = passwordHash,
EmailConfirmed = true,
Roles = {"Admin"}
};
session.StoreAsync(superUser);
session.SaveChangesAsync();
}
示例6: SaveEntity
protected static async Task SaveEntity(IEntity entity, IAsyncDocumentSession session)
{
await session.StoreAsync(entity);
await session.SaveChangesAsync();
}
示例7: Save
public void Save(IAsyncDocumentSession session, Action<object> callback)
{
session.Store(jsonDocument);
session.SaveChangesAsync();
Id = jsonDocument.Key;
}
示例8: StoreDataAsync
public async Task StoreDataAsync(DocumentStore store, IAsyncDocumentSession session)
{
for (var i = 1; i <= Cntr; i++)
{
await session.StoreAsync(new User {Name = "Test User #" + i}, "users/" + i);
}
await session.SaveChangesAsync();
}
示例9: AddUsers
// privates
private static async Task AddUsers(IAsyncDocumentSession ses)
{
await ses.StoreAsync(new RavenUser { UserName = "Tugberk", Roles = new List<RavenUserRole> { new RavenUserRole { Id = "Admin" }, new RavenUserRole { Id = "Guest" } } });
await ses.StoreAsync(new RavenUser { UserName = "Tugberk2", Roles = new List<RavenUserRole> { new RavenUserRole { Id = "Admin" } } });
await ses.StoreAsync(new RavenUser { UserName = "Tugberk2", Roles = new List<RavenUserRole> { new RavenUserRole { Id = "Guest" } } });
await ses.SaveChangesAsync();
}