ASP.NET MVC 4 Tutorial :: Build async Unit of Work with ASP.NET MVC 4
Build async Unit of Work with ASP.NET MVC 4 – ASP.NET 5 Hosting | In the RavenDB mailing list, How to combine the standard unit of work pattern of working with RavenDB in MVC applications with async. In particular, the problematic code was:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | public class HomeController : Controller { public IAsyncDocumentSession Db { get; set; } public async Task<ActionResult> Index() { var person = new Person {Name = "Khalid Abuhakmeh"}; await Db.StoreAsync(person); return View(person); } protected override void OnActionExecuting(ActionExecutingContext filterContext) { Db = MvcApplication.DocumentStore.OpenAsyncSession(); base.OnActionExecuting(filterContext); } protected override void OnActionExecuted(ActionExecutedContext filterContext) { Db.SaveChangesAsync() .ContinueWith(x => { }); base.OnActionExecuted(filterContext); } lic class Person { public string Id { get; set; } public string Name { get; set; } } } |
As you probably noticed, the problem Db.SaveChangesAsync(). We want to execute[…]