Entities best practices #8765
Unanswered
terrypascal
asked this question in
General
Replies: 1 comment 1 reply
-
If the database has somehow data with empty title, your select query which includes that data will throw always that exception. Even ORM can't set that property while reading from database. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
On the following page: https://docs.abp.io/en/abp/latest/Best-Practices/Entities
The suggestion is to validate a property, that an independent "setter" method should be used, and then to make private the property setter.
C#.NET was developed with this concept in mind so that validation could be added at any time during an application life cycle without affecting class users/clients.
private string _title;
public virtual string Title
{
get => _title;
set => _title = Check.NotNullOrWhiteSpace(value, nameof(value));
}
There are already built in getters and setters. To be used for validation, simply write the validator logic within the setter.
Beta Was this translation helpful? Give feedback.
All reactions