var about = new About { Heading = $"My heading 2" }; await session.StoreAsync(about);
var metadata = session.Advanced.GetMetadataFor(about); metadata.Add("Name","FooBar");
await session.SaveChangesAsync();
store.OnAfterSaveChanges += (object sender, AfterSaveChangesEventArgs args) => { var name = args.DocumentMetadata["Name"]; };
Exception has occurred: CLR/System.Collections.Generic.KeyNotFoundExceptionAn exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in Raven.Client.dll but was not handled in user code: 'Name is not in the metadata' at Raven.Client.Json.MetadataAsDictionary.get_Item(String key) in C:\Builds\RavenDB-Stable-4.0\src\Raven.Client\Json\MetadataAsDictionary.cs:line 89 at src.ServiceCollectionExtensions.<>c.<.cctor>b__9_1(Object sender, AfterSaveChangesEventArgs args) in /Users/maqe/temp/aspnet5/src/ServiceCollectionExtensions.cs:line 53 at Raven.Client.Documents.Session.Operations.BatchOperation.SetResult(BlittableArrayResult result) in C:\Builds\RavenDB-Stable-4.0\src\Raven.Client\Documents\Session\Operations\BatchOperation.cs:line 45 at Raven.Client.Documents.Session.AsyncDocumentSession.<SaveChangesAsync>d__20.MoveNext() in C:\Builds\RavenDB-Stable-4.0\src\Raven.Client\Documents\Session\AsyncDocumentSession.cs:line 124
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
Entities can be marked for deletion by using the Delete method, but will not be removed from the server until SaveChanges is called. koden här...
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
store.OnAfterSaveChanges += (object sender, AfterSaveChangesEventArgs args) => {
if(args.Entity.GetType().GetCustomAttributes(typeof(ViewModelAttribute), false).Any()) {
var controllerType = args.Entity.GetType().Name; var key = args.DocumentMetadata["Url"]; PatchCommandData patchCommandData = new PatchCommandData($"sites/{requestCultureFeature.RequestCulture.Culture.Name}", null, new PatchRequest { Script = "this.Trie[args.Key] = args.TrieNode", Values = { { "TrieNode", new TrieNode(args.DocumentId, controllerType) { Name = controllerType } }, { "Key", $"{key}" } } }, null);
((IAsyncDocumentSession)args.Session).Advanced.Defer(patchCommandData); } };
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
using(var session = _documentStore.OpenAsyncSession()) {
var about = new About { Heading = $"My heading 2" }; await session.StoreAsync(about);
var metadata = session.Advanced.GetMetadataFor(about);
metadata.Add("Url", "/about");
await session.SaveChangesAsync();
};
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
[Fact] public void Test() { using (var documentStore = GetDocumentStore()) { using (var session = documentStore.OpenSession())
{ session.Advanced.OnBeforeStore += (sender, args) => {
// Access the document metadata so I can create a new entry in the Trie using the Patch API var url = args.DocumentMetadata["Url"]; };
// Create a new document var document = new Document { Id = "my-id/123" };
session.Store(document);
// Add new metadata to the newly added document var metadata = session.Advanced.GetMetadataFor(document); metadata["Url"] = "/my-url";
session.SaveChanges(); } } }
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.