Skip to main content

Class Attribute Reference

This page is a full reference for the class-level attributes available in Cognibase.

Attribute Hierarchy

SecurityObjectAttribute
└── RuntimeClassAttribute [RuntimeClass]
└── PersistedClassAttribute [PersistedClass]

PersistedClassAttribute inherits all options from RuntimeClassAttribute, which in turn inherits security options from SecurityObjectAttribute.

[PersistedClass]

Applied to classes that are saved to the database and synchronized across all nodes.

[PersistedClass]
public class Order : DataItem { ... }

Persistence Options

OptionTypeDefaultDescription
PersistedAsstring(class name)Override the database table name
IsArchivableboolfalseEnables the archival workflow for instances of this class
IsClientPreLoadedboolfalseInstructs the Client Object Manager to load all instances of this class automatically on startup
IsServerPreLoadedboolfalseInstructs the Server Object Manager to load all instances of this class automatically on startup
TrackExactRefByChangesboolfalseEnables precise tracking of reverse references
IdPersistenceModeDataItemIdPersistenceModeDefaultControls how this class's identity key is stored

Example — Class with Storage Options

// Loaded on both client and server at startup; stored in a custom table name
[PersistedClass(
PersistedAs = "tbl_screen",
IsClientPreLoaded = true,
IsServerPreLoaded = true)]
public class Screen : DataItem
{
[PersistedProperty(IdOrder = 1, AutoValue = AutoValue.Identity)]
public long Id { get => getter<long>(); set => setter(value); }

[PersistedProperty(IsMandatory = true)]
public string HostAddress { get => getter<string>(); set => setter(value); }

[PersistedProperty]
public int Width { get => getter<int>(); set => setter(value); }

[PersistedProperty]
public int Height { get => getter<int>(); set => setter(value); }
}

[RuntimeClass]

Applied to classes that are synchronized across all nodes but are never saved to the database, as they are only in-memory stored.

[RuntimeClass]
public class LiveAlert : DataItem { ... }

[PersistedClass] inherits all options listed below, so these apply to both attribute types.

Behaviour Options

OptionTypeDefaultDescription
IsTemplateboolfalseMarks the class as a template — not directly instantiated
Descriptionstring""Human-readable description of the class
IsClientCachedboolfalseCache instances on the client
IsServerCachedboolfalseCache instances on the server
IsNotifyingReferrersOnChangeboolfalseWhen a property changes, notify all objects that hold a reference to this object
HasRuleViolationsbooltrueEnables the rule-violation framework for this class
IsSafeInsertbooltrueUse safe-insert semantics when creating new instances

Display and Binding Options

OptionTypeDefaultDescription
ClassDisplayModeDeclarativePropertyDisplayModeScalarAndReferencesControls which properties are surfaced in auto-generated UI
ClassBindModeDeclarativePropertyBindModeScalarAndReferencesControls which properties participate in auto data-binding
SignatureModeSignatureModeDefaultHow the object's signature string is composed
SignaturePrefixstringnullPrefix added before the signature string
SignatureSuffixstringnullSuffix added after the signature string
SignatureSeparatorstringnullSeparator used between signature components
DisplaySettingsHandlerMethodNamestringnullName of the method that returns display settings for this object

Collision and Change-Stream Options

OptionTypeDefaultDescription
ReferenceByHandlingModeReferenceByHandlingModeDelegateHow reference-by relationships are handled
ChangeStreamModeChangeStreamModeDelegateStreaming behaviour for change events
CollisionClientHandlingModeCollisionClientHandlingModeDelegateHow the client resolves concurrent edit collisions
CollisionServerHandlingModeCollisionServerHandlingModeDelegateHow the server resolves concurrent edit collisions

Field Load Error Options

OptionTypeDefaultDescription
FieldLoadErrorMonitorModeFieldLoadErrorMonitorModeOnWhether field-load errors are monitored
FieldLoadErrorReportModeFieldLoadErrorReportModeDelegateHow field-load errors are reported
FieldLoadErrorValueDeliveryModeFieldLoadErrorValueDeliveryModeDelegateWhat value is delivered when a field-load error occurs
FieldLoadAgingModeFieldLoadAgingModeDelegateHow field aging is applied on this class
FieldLoadAgingDelaystring""Delay duration for field aging

Security Options (inherited from SecurityObjectAttribute)

OptionTypeDefaultDescription
SecurityEnabledbooltrueWhether security checks are evaluated for this class
SecurityLabelstring""Label shown for this object in security management UI
SecurityHeaderstring""Column header shown in security lists
SecurityDescriptionstring""Description shown in security management UI
SecurityDisplayOrderint0Sort order in security management lists

Per-operation security defaults (all bool, all default true):

  • SecurityDefaultLoadAllow
  • SecurityDefaultBrowseAllow
  • SecurityDefaultDisplayAllow
  • SecurityDefaultSaveNewAllow
  • SecurityDefaultSaveUpdatedAllow
  • SecurityDefaultSaveDeletedAllow
  • SecurityDefaultSaveArchivedAllow
  • SecurityDefaultFieldDisplayAllow
  • SecurityDefaultFieldChangeAllow
  • SecurityDefaultActionExecuteAllow
  • SecurityDefaultDataLoadAllow
  • SecurityDefaultDataBrowseAllow
  • SecurityDefaultDataDisplayAllow

Example — Runtime Class with Security

[RuntimeClass(
Description = "Live operational status of a display screen",
IsClientCached = true,
SecurityOnFields = true,
SecurityDefaultFieldChangeAllow = false)] // fields are read-only by default
public class ScreenStatus : DataItem
{
[RuntimeProperty]
public bool IsOnline { get => getter<bool>(); set => setter(value); }

[RuntimeProperty]
public string ActiveContentName { get => getter<string>(); set => setter(value); }

[RuntimeProperty]
public DateTime LastHeartbeat { get => getter<DateTime>(); set => setter(value); }
}

Abstract Classes

You can mark any DataItem subclass as abstract. The class still carries [PersistedClass] or [RuntimeClass], but cannot be instantiated directly. Concrete subclasses inherit all annotated properties:

// Abstract base — defines shared structure
[PersistedClass]
public abstract class MediaFile : DataItem
{
[PersistedProperty(IdOrder = 1, AutoValue = AutoValue.Identity)]
public long Id { get => getter<long>(); set => setter(value); }

[PersistedProperty(IsMandatory = true)]
public string FileName { get => getter<string>(); set => setter(value); }

[PersistedProperty]
public long FileSizeBytes { get => getter<long>(); set => setter(value); }
}

// Concrete subclass — adds image-specific fields
[PersistedClass]
public class ImageFile : MediaFile
{
[PersistedProperty]
public int PixelWidth { get => getter<int>(); set => setter(value); }

[PersistedProperty]
public int PixelHeight { get => getter<int>(); set => setter(value); }

[PersistedProperty]
public ImageBLOB Thumbnail { get => getter<ImageBLOB>(); set => setter(value); }
}

// Concrete subclass — adds video-specific fields
[PersistedClass]
public class VideoFile : MediaFile
{
[PersistedProperty]
public TimeSpan Duration { get => getter<TimeSpan>(); set => setter(value); }

[PersistedProperty]
public BLOB Data { get => getter<BLOB>(); set => setter(value); }
}

A property typed as MediaFile can hold a reference to an ImageFile or a VideoFile instance:

[PersistedClass]
public class PlaylistItem : DataItem
{
[PersistedProperty(IdOrder = 1, AutoValue = AutoValue.Identity)]
public long Id { get => getter<long>(); set => setter(value); }

// Can reference any concrete MediaFile subtype
[PersistedProperty(IsMandatory = true)]
public MediaFile File { get => getter<MediaFile>(); set => setter(value); }
}

Non-Compressible Classes

By default, Cognibase may compress object payloads during network transfer. To opt a class out of compression — for example because it already stores compressed binary data — apply [NonCompressible]:

[NonCompressible]
[PersistedClass]
public class VideoClipFile : MediaFile
{
[PersistedProperty]
public BLOB CompressedData { get => getter<BLOB>(); set => setter(value); }
}

Custom Persistence Provider

If you need to override how a class's data is stored and retrieved (e.g. to map it against a legacy schema or an external API), implement ICustomPersistenceProvider and attach it with [PersistWith]:

[PersistWith(PersistenceProviderType = typeof(LegacyOrderPersistenceProvider))]
[PersistedClass]
public class LegacyOrder : DataItem
{
[PersistedProperty(IdOrder = 1)]
public string OrderNumber { get => getter<string>(); set => setter(value); }
// ...
}