Confinity Documentation
  • Latest Version
  • Latest Version
  • Getting Started

    • Introduction
    • Core Concepts
    • Create an Application
    • Glossary
  • Essentials

    • Authentication & SSO
    • Breaking Changes
    • Roslyn Source Analyzers
    • Changelog
    • ConfinityContent
    • ConfinitySelectable
    • Confinity Schedules
    • Data Seeding
    • Development guidelines [WIP]
    • Entity App
    • Entity Form
    • Entity Permissions
    • Frontend Configuration
    • Images
    • Known Issues
    • Localization
    • Migrations
    • Modules [WIP]
    • On-Site Editing
    • Settings
    • Cascade Delete
    • Replication
    • Infrastructure
  • Modules

    • Analytics Module
    • Assets Module
    • Blog Module
    • Cookie Consent Module
    • Forms Module
    • Friendly Captcha (Forms Module )
    • GeoIP Module
    • Htmx
    • Mail Module
    • Mailing Module
    • MediaPlayer Module
    • GoogleMyBusiness Module
    • OpenTelemetry Module
    • Pages Module [WIP]
    • Pattern Library Module
    • SIX Saferpay (worldline) Module
    • Products Module
    • Search Module
    • Wizard Module
  • Guides

    • Create a Custom Entity App Form Element
    • Date and Time
    • Entity Change Listener
    • File Upload / Temp File
    • HTTP security headers
    • conventions [WIP]
    • How to use Confinity with nginx
    • Notifications
    • Nullability
    • Rename Entity
    • Schedules
    • Useful snippets
    • Content Localization
  • Design Guidelines

    • Introduction
    • Page Components
    • Forms Module

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.

Prev
Notifications
Next
Rename Entity