Nullability
In order to avoid problems with properties of nullable value- and reference types, the following rules are recommended when working with Confinity.
Entities
Use properties with the null-forgiving operator for non-nullable navigation properties, e.g.
public class TeamExample : ConfinityEntity
{
public Organization Organization { get; set; } = null!;
public Guid OrganizationId { get; set; }
public List<Worker> Members { get; set; } = null!;
}
Use non nullable properties with defaults for value types when a default is appropriate, e.g.
public class Account : ConfinityEntity
{
public decimal Balance { get; set; } = 0;
}
Use properties with defaults for lists of ConfinityContents, e.g.
public class Article : ConfinityEntity
{
public List<Content> Contents { get; set; } = [];
}
Use nullable properties for everything else, especially ConfinityContent, e.g.
public class PersonExample : ConfinityEntity
{
public string? FirstName { get; set; }
public string? LastName { get; set; }
public DateTime? Birthday { get; set; }
public ConfinityContent? AdditionalInformation { get; set; }
}
ConfinityContent
Warning
Never use the null-forgiving operator!
Except that, the same rules as for entities apply.