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
| Option | Type | Default | Description |
|---|---|---|---|
AutoValue | AutoValue | None | AutoValue.Identity makes the column an auto-increment primary key |
PersistedAs | string | (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
| Option | Type | Default | Description |
|---|---|---|---|
DataSourceType | DataSourceType | Internal | How the framework locates the backing storage for this property |
DataSourceName | string | null | Name of the backing field or data source |
IdOrder | int | -1 | Position of this property in the composite primary key; -1 means not part of the key |
DefaultValue | object | null | Value assigned to new instances when no explicit value is provided |
Validation Options
| Option | Type | Default | Description |
|---|---|---|---|
IsMandatory | bool | false | Rejects null (and empty string) values |
Min | double | — | Minimum numeric value (applies to numeric types) |
Max | double | — | Maximum numeric value (applies to numeric types) |
MinDate | string | "" | Minimum allowed date (ISO 8601 string) |
MaxDate | string | "" | Maximum allowed date (ISO 8601 string) |
MinTimeSpan | string | "" | Minimum allowed TimeSpan (string format) |
MaxTimeSpan | string | "" | Maximum allowed TimeSpan (string format) |
IsWriteOnce | bool | false | Value can be set at creation but cannot be changed afterwards |
ValueList | string | "" | Pipe-separated list of valid values |
Relationship Options
| Option | Type | Default | Description |
|---|---|---|---|
AssociationType | AssociationType | Association | Association, CompositionParent, or CompositionChild |
ReverseRef | string | null | Name of the corresponding property on the related class (enables bidirectional navigation) |
IsProxyRef | bool | false | Marks this property as a proxy reference |
Change-Stream and Loading Options
| Option | Type | Default | Description |
|---|---|---|---|
ChangeStreamMode | ChangeStreamMode | Delegate | Streaming behaviour for change events on this property |
FieldLoadErrorMonitorMode | FieldLoadErrorMonitorMode | On | Whether load errors on this field are monitored |
FieldLoadErrorReportMode | FieldLoadErrorReportMode | Delegate | How load errors on this field are reported |
FieldLoadErrorValueDeliveryMode | FieldLoadErrorValueDeliveryMode | Delegate | What value is returned when a load error occurs |
FieldLoadErrorValue | object | null | The specific fallback value delivered on load error |
FieldLoadAgingMode | FieldLoadAgingMode | Delegate | Whether this field's value ages out over time |
FieldLoadAgingDelay | string | "" | Duration before the field value is considered stale |
IsNotifyForImplicitFieldSaveEvent | bool | false | Raises a save event when the field is implicitly modified |
IsMethodData | bool | false | Indicates 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
| Option | Type | Description |
|---|---|---|
DataSourceName | string | Name of the underlying data source used during calculation |
Getter | string | Name of a method that provides the value (alternative to a lambda expression) |
BindingFlags | BindingFlags | Reflection 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
| Option | Type | Description |
|---|---|---|
Target | string | Dot-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:
| Option | Type | Default | Description |
|---|---|---|---|
Description | string | "" | Human-readable description |
ResourceId | string | null | Resource key for localization |
DisplayFormat | string | null | Format string for display |
EditMask | string | null | Input mask for editing |
IsDisplayed | bool | true | Whether this property is shown in auto-generated UI |
SignatureOrder | int | -1 | Position of this property in the object's signature string |
SignaturePrefix | string | null | Prefix added before this property's contribution to the signature |
SignatureSuffix | string | null | Suffix added after this property's contribution to the signature |
TabIndex | int | 0 | Tab order in auto-generated forms |
GroupName | string | "" | Groups related properties together in auto-generated UI |
HierarchyParent | bool | false | Marks this property as the parent link in a tree hierarchy |
HierarchyChildren | bool | false | Marks this property as the children collection in a tree hierarchy |
EditorType | Type | null | Custom editor component type |
EditorTypeId | DefaultTypeEditorId | None | Built-in editor identifier |
EditorContext | string | null | Context string passed to the editor |
ViewAsType | Type | null | Custom view component type |
EmptySpecifier | object | null | The value considered "empty" for this property |
IsNotifiedOnReferenceChange | bool | false | Raise a change notification when the referenced object itself changes |
MemberType | Type | null | Override the reported member type |
ValueFormatterType | Type | null | Custom formatter for display values |
Security Options (inherited from SecurityObjectAttribute)
| Option | Type | Default | Description |
|---|---|---|---|
SecurityEnabled | bool | true | Whether security checks apply to this property |
SecurityLabel | string | "" | Label shown in security management UI |
SecurityHeader | string | "" | Column header in security lists |
SecurityDescription | string | "" | Description in security management UI |
SecurityDisplayOrder | int | 0 | Sort order in security management lists |
Supported Scalar Types
Cognibase maps the following C# types to native database columns:
| C# Type | Notes |
|---|---|
string | Variable-length text |
bool | Boolean flag |
int | 32-bit integer |
long | 64-bit integer (common for identity keys) |
float | Single-precision floating-point |
double | Double-precision floating-point |
decimal | High-precision decimal |
DateTime | Date and time |
TimeSpan | Duration |
Guid | Globally unique identifier |
Any C# enum | Stored as its underlying integer value |
BLOB | Binary large object (raw bytes) |
ImageBLOB | Image 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:
| Option | Type | Description |
|---|---|---|
GateName | string | Name of the gateway to use |
GateType | string | Type identifier of the gateway |
GateId | string | Identifier within the gateway |
GateMapMode | GateMapMode | How the mapping is applied |
GateDataSourceId | string | Data-source identifier within the gateway |
GateWriteActionName | string | Name of the write action on the gateway |
GateLoadHint | string | Hint passed to the gateway on load |
IsGateDataSourcePath | bool | Treats GateDataSourceId as a path |
IsGateLoadHint | bool | Enables the load hint |
IsGateWritable | bool | Enables write-back to the gateway |