Skip to main content

Property Attribute Reference

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

Attribute Hierarchy

SecurityObjectAttribute
└── PropertyAttribute
├── RuntimePropertyAttribute [RuntimeProperty]
│ └── PersistedPropertyAttribute [PersistedProperty]
├── CalculativePropertyAttribute [CalculativeProperty]
└── IndirectPropertyAttribute [IndirectProperty]

[PersistedProperty]

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

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

[PersistedProperty] extends [RuntimeProperty] and inherits all options listed in the [RuntimeProperty] section below.

Persistence-Specific Options

OptionTypeDefaultDescription
AutoValueAutoValueNoneAutoValue.Identity makes the column an auto-increment primary key
PersistedAsstring(property name)Overrides the database column name

Identity Key Pattern

Use IdOrder (inherited from [RuntimeProperty]) together with AutoValue.Identity to declare primary keys:

// Single auto-increment identity key
[PersistedProperty(IdOrder = 1, AutoValue = AutoValue.Identity)]
public long Id { get => getter<long>(); set => setter(value); }

// Composite key — two fields together form the unique identifier
[PersistedProperty(IdOrder = 1)]
public long RegionId { get => getter<long>(); set => setter(value); }

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

// String-based natural key
[PersistedProperty(IdOrder = 1)]
public string IsoCode { get => getter<string>(); set => setter(value); }

[RuntimeProperty]

Applied to properties that are distributed in real-time but are never saved to the database. Can appear on both [RuntimeClass] and [PersistedClass] entities:

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

Data-Source Options

OptionTypeDefaultDescription
DataSourceTypeDataSourceTypeInternalHow the framework locates the backing storage for this property
DataSourceNamestringnullName of the backing field or data source
IdOrderint-1Position of this property in the composite primary key; -1 means not part of the key
DefaultValueobjectnullValue assigned to new instances when no explicit value is provided

Validation Options

OptionTypeDefaultDescription
IsMandatoryboolfalseRejects null (and empty string) values
MindoubleMinimum numeric value (applies to numeric types)
MaxdoubleMaximum numeric value (applies to numeric types)
MinDatestring""Minimum allowed date (ISO 8601 string)
MaxDatestring""Maximum allowed date (ISO 8601 string)
MinTimeSpanstring""Minimum allowed TimeSpan (string format)
MaxTimeSpanstring""Maximum allowed TimeSpan (string format)
IsWriteOnceboolfalseValue can be set at creation but cannot be changed afterwards
ValueListstring""Pipe-separated list of valid values

Relationship Options

OptionTypeDefaultDescription
AssociationTypeAssociationTypeAssociationAssociation, CompositionParent, or CompositionChild
ReverseRefstringnullName of the corresponding property on the related class (enables bidirectional navigation)
IsProxyRefboolfalseMarks this property as a proxy reference

Change-Stream and Loading Options

OptionTypeDefaultDescription
ChangeStreamModeChangeStreamModeDelegateStreaming behaviour for change events on this property
FieldLoadErrorMonitorModeFieldLoadErrorMonitorModeOnWhether load errors on this field are monitored
FieldLoadErrorReportModeFieldLoadErrorReportModeDelegateHow load errors on this field are reported
FieldLoadErrorValueDeliveryModeFieldLoadErrorValueDeliveryModeDelegateWhat value is returned when a load error occurs
FieldLoadErrorValueobjectnullThe specific fallback value delivered on load error
FieldLoadAgingModeFieldLoadAgingModeDelegateWhether this field's value ages out over time
FieldLoadAgingDelaystring""Duration before the field value is considered stale
IsNotifyForImplicitFieldSaveEventboolfalseRaises a save event when the field is implicitly modified
IsMethodDataboolfalseIndicates the property value comes from a method call

Example — Full Property Annotation

[PersistedClass]
public class Tile : DataItem
{
// Auto-increment identity key
[PersistedProperty(IdOrder = 1, AutoValue = AutoValue.Identity)]
public long Id { get => getter<long>(); set => setter(value); }

// Mandatory string with a custom column name in the database
[PersistedProperty(IsMandatory = true, PersistedAs = "tile_description")]
public string Description { get => getter<string>(); set => setter(value); }

// Numeric fields with range constraints
[PersistedProperty(DefaultValue = 0.0f)]
public float X { get => getter<float>(); set => setter(value); }

[PersistedProperty(DefaultValue = 0.0f)]
public float Y { get => getter<float>(); set => setter(value); }

[PersistedProperty(Min = 0.1, Max = 10.0, DefaultValue = 1.0f)]
public float Scale { get => getter<float>(); set => setter(value); }

// Write-once serial number
[PersistedProperty(IsWriteOnce = true)]
public string SerialNumber { get => getter<string>(); set => setter(value); }

// Runtime property — live state, not persisted
[RuntimeProperty]
public bool IsSelected { get => getter<bool>(); set => setter(value); }
}

[CalculativeProperty]

A calculative property returns a value computed entirely by your code. It is neither persisted nor distributed to other nodes.

[CalculativeProperty]
public string DisplayLabel => $"[{Code}] {Name}";

Options

OptionTypeDescription
DataSourceNamestringName of the underlying data source used during calculation
GetterstringName of a method that provides the value (alternative to a lambda expression)
BindingFlagsBindingFlagsReflection flags used to locate the Getter method

Example — Using a Named Getter Method

[CalculativeProperty(Getter = nameof(ComputeStatus))]
public string Status { get; }

private string ComputeStatus()
{
return IsOnline ? $"Online ({LastSeen:HH:mm})" : "Offline";
}

[IndirectProperty]

An indirect property navigates through a reference chain to expose a value from a related object. It is neither persisted nor distributed.

// Exposes the name of the category this product belongs to
[IndirectProperty(Target = "Category.Name")]
public string CategoryName { get; }

Options

OptionTypeDescription
TargetstringDot-separated navigation path to the source value

Example — Multi-Level Navigation

[PersistedClass]
public class Tile : DataItem
{
[PersistedProperty(AssociationType = AssociationType.CompositionChild,
ReverseRef = nameof(Canvas.Tiles))]
public Canvas Canvas { get => getter<Canvas>(); set => setter(value); }

// Navigates Canvas → Name
[IndirectProperty(Target = "Canvas.Name")]
public string CanvasName { get; }
}

Shared Options (from PropertyAttribute)

All property attributes inherit the following display and UI options:

OptionTypeDefaultDescription
Descriptionstring""Human-readable description
ResourceIdstringnullResource key for localization
DisplayFormatstringnullFormat string for display
EditMaskstringnullInput mask for editing
IsDisplayedbooltrueWhether this property is shown in auto-generated UI
SignatureOrderint-1Position of this property in the object's signature string
SignaturePrefixstringnullPrefix added before this property's contribution to the signature
SignatureSuffixstringnullSuffix added after this property's contribution to the signature
TabIndexint0Tab order in auto-generated forms
GroupNamestring""Groups related properties together in auto-generated UI
HierarchyParentboolfalseMarks this property as the parent link in a tree hierarchy
HierarchyChildrenboolfalseMarks this property as the children collection in a tree hierarchy
EditorTypeTypenullCustom editor component type
EditorTypeIdDefaultTypeEditorIdNoneBuilt-in editor identifier
EditorContextstringnullContext string passed to the editor
ViewAsTypeTypenullCustom view component type
EmptySpecifierobjectnullThe value considered "empty" for this property
IsNotifiedOnReferenceChangeboolfalseRaise a change notification when the referenced object itself changes
MemberTypeTypenullOverride the reported member type
ValueFormatterTypeTypenullCustom formatter for display values

Security Options (inherited from SecurityObjectAttribute)

OptionTypeDefaultDescription
SecurityEnabledbooltrueWhether security checks apply to this property
SecurityLabelstring""Label shown in security management UI
SecurityHeaderstring""Column header in security lists
SecurityDescriptionstring""Description in security management UI
SecurityDisplayOrderint0Sort order in security management lists

Supported Scalar Types

Cognibase maps the following C# types to native database columns:

C# TypeNotes
stringVariable-length text
boolBoolean flag
int32-bit integer
long64-bit integer (common for identity keys)
floatSingle-precision floating-point
doubleDouble-precision floating-point
decimalHigh-precision decimal
DateTimeDate and time
TimeSpanDuration
GuidGlobally unique identifier
Any C# enumStored as its underlying integer value
BLOBBinary large object (raw bytes)
ImageBLOBImage binary data with metadata

Synchronization Constraints with [SyncReq]

When two properties on the same class must always be saved together — for example a pair of coordinates — annotate the class with [SyncReq] to instruct the framework to include both in every save event:

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

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

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

Multiple [SyncReq] attributes can be placed on the same class.

Gate Mapping Options

Property attributes support a set of Gate options that bind Cognibase properties to external data sources (gateways). These are used when integrating Cognibase with legacy systems or real-time data feeds:

OptionTypeDescription
GateNamestringName of the gateway to use
GateTypestringType identifier of the gateway
GateIdstringIdentifier within the gateway
GateMapModeGateMapModeHow the mapping is applied
GateDataSourceIdstringData-source identifier within the gateway
GateWriteActionNamestringName of the write action on the gateway
GateLoadHintstringHint passed to the gateway on load
IsGateDataSourcePathboolTreats GateDataSourceId as a path
IsGateLoadHintboolEnables the load hint
IsGateWritableboolEnables write-back to the gateway