Changes on metadata is not included in WhatChanged?

12 views
Skip to first unread message

marcus

unread,
Feb 24, 2018, 5:07:06 AM2/24/18
to RavenDB - 2nd generation document database
Should'n changes on metadata be included when checking what changed on a document?

In my example the modified metadata is not included in WhatChanged?


            using(var session = _documentStore.OpenAsyncSession()) {
                var about = await session.LoadAsync<About>("abouts/385-A");
                about.Heading = "Edited page";

                var metadata = session.Advanced.GetMetadataFor(about);
                metadata["Name"] = "A new page";
                metadata["Url"] = "/a-new-page";

                IDictionary<string, DocumentsChanges[]> changes = session.Advanced.WhatChanged();
                DocumentsChanges[] aboutChanges = changes["abouts/385-A"];

                await session.StoreAsync(about);
                await session.SaveChangesAsync();
            };


Oren Eini (Ayende Rahien)

unread,
Feb 25, 2018, 2:15:27 AM2/25/18
to ravendb
No, it's there, but it is probably the last thing there. See passing test:

      [Fact]
        public void MetadataChangesAreAvailableForWhatChanged()
        {

            using (var store = GetDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    session.Advanced.OnBeforeStore += (sender, args) =>
                    {
                        args.DocumentMetadata["Value"] = "a";
                    };

                    session.Store(new Document
                    {
                        Id = "my-id/123"
                    });

                    session.SaveChanges();
                }

                using (var session = store.OpenSession())
                {
                    var doc = session.Load<Document>("my-id/123");
                    var metadata = session.Advanced.GetMetadataFor(doc);
                    metadata["Value"] = "b";

                    var changes = session.Advanced.WhatChanged()["my-id/123"];


                    Assert.Equal(ChangeType.FieldChanged, changes.Last().Change);
                    Assert.Equal("Value", changes.Last().FieldName);
                }
            }
        }

Hibernating Rhinos Ltd  

Oren Eini l CEO 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.

Reply all
Reply to author
Forward
0 new messages