Giter Club home page Giter Club logo

Comments (3)

rivantsov avatar rivantsov commented on August 29, 2024

looking at it.

from vita.

rivantsov avatar rivantsov commented on August 29, 2024

Hi, and sorry it took so long. I am preparing update, and looked at this issue.

It looks like it works correctly. I'm afraid there's some confusion here. The goal is not to 'fire', but to mark parent/target entity as Modified whenever child is added, updated or deleted. For update and delete, an event fires on child entity, attribute handles it, reaches to the parent and marks it Modified if its status is Loaded. Simple. For added child record, it is a bit different. The New event is fired immediately when it is created; it is empty yet, parent ref is not assigned. So instead, I intercept assignment of the parent ref to the child property. Look at the code in the attribute, SetMemberValue interceptor.

I wrote a test method for adding a BookOrderLine to existing order:

    // Investigating reported issue #202: PropagateUpdatedOn does not trigger when adding new line
    // Dec 2022 - so far no problem detected, works as expected without fixes

    [TestMethod]
    public void TestBugPropagateUpdatedOnAttr() {
      Startup.BooksApp.LogTestStart();

      var app = Startup.BooksApp;
      var session = app.OpenSession();

      // IBookOrderLine has [PropagateUpdateOn] on Order property. 
      // For an existing order, after we add/modify/delete any line, the parent Order's status should be Modified, and UpdatedOn field should be updated 
      //  on SaveChanges.

      // We create order with one book; save it; and then add another book - the BookOrder should be set to Modified
      var ferb = session.EntitySet<IUser>().First(u => u.UserName == "Ferb");
      var order = session.NewOrder(ferb);
      var csBook = session.EntitySet<IBook>().First(b => b.Title.StartsWith("c#"));
      order.Add(csBook, 1);
      session.SaveChanges();

      var orderRec = EntityHelper.GetRecord(order);
      Assert.AreEqual(EntityStatus.Loaded, orderRec.Status);
      var updOn = order.UpdatedOn;
      Thread.Sleep(100); // to make difference in UpdatedOn noticeable

      // now lets add another book and check the order status
      var vbBook = session.EntitySet<IBook>().First(b => b.Title.StartsWith("VB"));
      order.Add(vbBook, 1);
      // Check that order state changed to modified
      Assert.AreEqual(EntityStatus.Modified, orderRec.Status, "Expected Order status changed to Modified");
      session.SaveChanges();
      var newUpdOn = order.UpdatedOn;
      Assert.IsTrue(newUpdOn > updOn.AddMilliseconds(50), "Expected later new UpdatedOn value");
    }

this test will be in coming update.

from vita.

jasonlaw avatar jasonlaw commented on August 29, 2024

Ok thanks!

from vita.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.