public async Task<FarmAreaSaveModel> Save(FarmAreaSaveModel model) { using (var docStore = new DocumentStore()) { docStore.ConnectionStringName = "RavenHQ"; docStore.Conventions = new DocumentConvention {IdentityPartsSeparator = "-"}; docStore.Initialize(); using (var session = docStore.OpenAsyncSession()) { var farmArea = model.Id.IsNullOrEmpty() ? new FarmArea() : await session.LoadAsync<FarmArea>(model.Id) ?? new FarmArea(); farmArea.Name = model.Name; await session.StoreAsync(farmArea); model.Id = farmArea.Id; model.Success = true; model.Message = "Saved farm area"; await session.SaveChangesAsync(); return model; } } }
This code works as expected
public FarmAreaSaveModel Save(FarmAreaSaveModel model) { using (var docStore = new DocumentStore()) { docStore.ConnectionStringName = "RavenHQ"; docStore.Conventions = new DocumentConvention { IdentityPartsSeparator = "-" }; docStore.Initialize(); using (var session = docStore.OpenSession()) { var farmArea = model.Id.IsNullOrEmpty() ? new FarmArea() : session.Load<FarmArea>(model.Id) ?? new FarmArea(); farmArea.Name = model.Name; session.Store(farmArea); model.Id = farmArea.Id; model.Success = true; model.Message = "Saved farm area"; session.SaveChanges(); return model; } } }
Hibernating Rhinos Ltd
Oren Eini l CEO l Mobile: + 972-52-548-6969
Office: +972-4-622-7811 l Fax: +972-153-4-622-7811
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.