Comments (3)
looking at it.
from vita.
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.
Ok thanks!
from vita.
Related Issues (20)
- Is vita Support SAP Sql Anywhere Database ? HOT 1
- Small request HOT 4
- Queryable/Enumerable method MaxBy not supported. HOT 2
- ExecuteNonQuery error with "No database selected" HOT 4
- [Need advice] Multi-tenant design HOT 2
- News for Vita ORM HOT 2
- Version 3.5 pushed. HOT 9
- Correct way to maintain sessions HOT 2
- Force all columns to be written to database HOT 7
- PostgreSQL - batch update failed HOT 9
- ViewHelper.EntitySet HOT 21
- GUID with Auto HOT 1
- DB Function Error HOT 2
- Left outer join view on multiple columns HOT 7
- Allow reference entity without creating foreign key constraint in table HOT 5
- Session schedule insert or update HOT 4
- DBFunction error HOT 3
- ExecuteDelete missing parenthesis HOT 4
- View does not group by datetime date HOT 3
- Functions like createdOn.Date are ignored in GroupBy HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vita.