You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
The current T4 files are generating code that calls OnPropertyChanged whenever the setter of a property is called (even if the value doesnt change). According to the example in How to: Implement the INotifyPropertyChanged Interface OnPropertyChanged is only called when there is a actual change of the value (also my personal preference since it avoids unecessary events).
I'm now using a modifed EFDesigner.ttinclude in my project which generates the following code for the properties:
#region Property Name of type string
[Required]protectedstring_Name;/// <summary>/// Required, Min length = 250/// </summary>publicstringName{get{return _Name;}set{if(_Name!=value){stringoldName=_Name;NameChanging(oldName,value);_Name=value;OnPropertyChanged(nameof(Name));NameChanged(oldName,value);}}}partialvoidNameChanging(stringoldName,stringnewName);partialvoidNameChanged(stringoldName,stringnewName);
#endregion
Below is the modified method in the modified EFDesigner.ttinclude which I have included in my project. I has the improved OnPropertyChanged handling and it also excludes the ConccurencyToken from calling OnPropertyChanged.
I've given this a deep look and made the decision not to add the OnChainging and OnChanged handlers. The partials that exist so the programmer can intervene in the value that's set serve the same purpose, in the general sense, so the same codebase can dual wield for both use cases.
The nice thing, as you've discovered, is that you can change it to suit your needs. I'll be focused on the most generally useful thing (usually following the 80/20 rule as much as possible), but everyone's able and welcome to morph it to their heart's content. I did add a few fixes and removed some dead code, and those are in the v1.2.6.7 release.
I will be adding more documentation on this feature when I get a moment. I've put a placeholder in the docs and a note in the TODO list so I don't forget. You're right that this needs more explanation that I've currently given it (read: hardly any!), so I'll try to get to that as soon as time and my wife permit.
- An entity's concurrency token property is no longer a required parameter in its constructor (#24)
- Simplified cascade delete settings in property editor for associations
- Fixed bad code generation in EFCore for cascade delete overrides (#22)
- Missing files when generating code for .NET Core projects fixed
- Tightened up and swatted some bugs in INotifyPropertyChanged handling. Added documentation to doc site for this feature (following up on #23)
- Ensured multiline editing was available in property window for those properties that made sense
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The current T4 files are generating code that calls OnPropertyChanged whenever the setter of a property is called (even if the value doesnt change). According to the example in How to: Implement the INotifyPropertyChanged Interface OnPropertyChanged is only called when there is a actual change of the value (also my personal preference since it avoids unecessary events).
I'm now using a modifed EFDesigner.ttinclude in my project which generates the following code for the properties:
Below is the modified method in the modified EFDesigner.ttinclude which I have included in my project. I has the improved OnPropertyChanged handling and it also excludes the ConccurencyToken from calling OnPropertyChanged.
The text was updated successfully, but these errors were encountered: