EntityHistoryHelper shouldn't create a PropertyChange for unchanged property
See original GitHub issueLet’s assume that we have not audited entity with a few properties, but only one of them is audited.
Current behavior: modifying other (non-audited properties) will cause EntityHistoryHelper
to create a PropertyChange
for audited property (even though it is unchanged).
Expected behavior:
propertyChange.NewValue = propertyEntry.GetNewValue()?.ToJsonString().TruncateWithPostfix(EntityPropertyChange.MaxValueLength);
if (!isAuditedProperty || propertyChange.OriginalValue == propertyChange.NewValue)
{
// No change
propertyChangesToRemove.Add(propertyChange);
}
Unchanged property shall should be removed from entity history if it’s (1) not audited OR (2) unmodified.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
EntityHistoryHelper shouldn't create a PropertyChange for ...
Appears to be working correctly except for datetime? properties are ... shouldn't create a PropertyChange for unchanged property #6294.
Read more >After setting EntityState.Unchanged the entity properties ...
After saving my changes, I have the correct student record in the database and also the book record remains unchanged, but whenever I...
Read more >Articles Tutorials | AspNet Boilerplate
Entity History tracks changes to complex type properties as property changes (unlike owned entities for EF Core). The original/new values of a complex...
Read more >Result of Change in Control, and/or Change in Ownership
Legal Entity Ownership Program (LEOP) – Result of Change in Control and/or Change in Ownership. The property that will be subject to reassessment...
Read more >Tax Reassessments of Transferred Property
Under Proposition 13,1 real property located in California is gen- erally reassessed when it is purchased, newly constructed, or a. “change in ownership”...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In this case I’d suggest comparing hashes of both
OriginalValue
andNewValue
as simply trimming both values is incorrect. Apparently, we need to store these hashes as a part ofEntityPropertyChange
.@demirmusa
First of all, there is no need not to trust the description and provided solution as it has already been discussed by 3 people, you could just apply the solution, cover that with unit-test and resolve the issue.
The first code snipped you’ve attached is not an “expected behavior” and If you were to check if issue is still present, you could just take a look at issue creation time (it has been made on 14th of Feb, 2020 while the latest change to
EntityHistoryHelper.cs
(ondev
branch) is dated Feb 7, 2020).The only difference is logical operator in IF-statement: Actual:
if (!isAuditedProperty && propertyChange.OriginalValue == propertyChange.NewValue)
Exepcted:if (!isAuditedProperty || propertyChange.OriginalValue == propertyChange.NewValue)
Related test-case should look like this: