concept object in category ravendb

appears as: n object, objects, object, object, objects
RavenDB in Action

This is an excerpt from Manning's book RavenDB in Action.

Figure 1.2 A .NET class and a JSON representation of an object of this class. This JSON document is exactly how a class of this object would look like once stored into RavenDB.
[HttpGet] public ActionResult Create() { return View(new Book()); } [HttpPost] public ActionResult Create(Book book) { if (!ModelState.IsValid) { return View(book); #A } RavenSession.Store(book); #B return Json("Book was successfully added and was assigned the ID " + book.Id, JsonRequestBehavior.AllowGet); #C } #A – checking the Model state from the submitted form. If it’s invalid we will return to show an error to the user. #B – Storing the new Book object we got from the form in the current RavenDB session. This will not store the object in the database just yet, just serialize it and assign it an ID. #C – Once the action method will return, SaveChanges() will get invoked in our base controller RavenController, and the new book object will be sent and persisted on the server. Our new book object has been assigned an ID by the client API on the call to Store(), so calling book.Id isn’t meaningless.