Example scenario: A SQL database has a column MyBoolean
. Instead of the standard bit
type, the type in the database is int
, and the value is always either 1
or 0
. The type in the database cannot be changed for compatibility reasons, and the type in the code cannot be changed due to how it interacts with the database.
For safety, a new property is introduced alongside MyBoolean
:
// ...
public int MyBoolean { get; set; }
[NotMapped]
public bool MyNewBoolean
{
get => MyBoolean == 1;
set => MyBoolean = value ? 1 : 0;
}
// ...
However, the database engine cannot understand how MyNewBoolean
translates to MyBoolean
, and therefore one must use MyBoolean
in queries. This means that MyBoolean
cannot be made private/protected/etc.
MyBoolean
is not obsolete as it is still in use, and it is not deprecated because its use is not discouraged. The property is also not planned to be removed. Is there another term for when one member is preferred in select circumstances?