Class TableRowBase
Summary description for TableBase.
Inheritance
Inherited Members
Namespace: SuperOffice.CRM.Rows
Assembly: SoDataBase.dll
Syntax
public abstract class TableRowBase : PrivateSave, INestedPersist, ISoDataLookup, ISentryIgnorable
Constructors
TableRowBase(IdxBase)
Constructor for the class, taking a unique index as argument
Declaration
protected TableRowBase(IdxBase idx)
Parameters
| Type | Name | Description |
|---|---|---|
| IdxBase | idx | The unique index used to load the object from the database. |
Fields
_isSaving
Summary description for TableBase.
Declaration
protected bool _isSaving
Field Value
| Type | Description |
|---|---|
| bool |
_relatedNestedPersistMembers
Summary description for TableBase.
Declaration
protected List<INestedPersist> _relatedNestedPersistMembers
Field Value
| Type | Description |
|---|---|
| List<INestedPersist> |
_saveOwner
Summary description for TableBase.
Declaration
protected INestedPersist _saveOwner
Field Value
| Type | Description |
|---|---|
| INestedPersist |
_sentries
Summary description for TableBase.
Declaration
protected SentryCollection _sentries
Field Value
| Type | Description |
|---|---|
| SentryCollection |
_sqlType
Summary description for TableBase.
Declaration
protected SqlType _sqlType
Field Value
| Type | Description |
|---|---|
| SqlType |
Properties
IsDeleted
Has the row been deleted in the database.
Declaration
public virtual bool IsDeleted { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsDirty
Is the row dirty, e.g. been modified since the last time it was saved to the database.
Declaration
public virtual bool IsDirty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsMarkedForDelete
Gets or sets a value indicating whether this instance is marked for delete.
Declaration
public bool IsMarkedForDelete { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
IsNew
Is the row new, e.g. not been inserted to the database?
Declaration
public abstract bool IsNew { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsSaving
Is the nested persist in a saving state, hence disable Sentry when reading id's
Declaration
public virtual bool IsSaving { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsSentryIgnored
Get value indicating whether sentry is ignored on the current object for the current thread.
Declaration
public override bool IsSentryIgnored { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
this[SoField]
Get or sets a value based on the SoField definition for a field
Declaration
public virtual object this[SoField fieldInfo] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| SoField | fieldInfo | Information about a field |
Property Value
| Type | Description |
|---|---|
| object | Value of the field. |
this[int]
Get or set a value based on the fields number.
Declaration
public virtual object this[int fieldId] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | fieldId | Number of hte field |
Property Value
| Type | Description |
|---|---|
| object | Value of the field. |
this[string]
Get or set a value based on the name of the field.
Declaration
public abstract object this[string fieldName] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| string | fieldName | Name of the field in the database |
Property Value
| Type | Description |
|---|---|
| object | Value of the field. |
Sentries
The collection of sentries that are guarding this row. This collection is automatically initialized by some HDB objects, and all RDB entities.
Declaration
public SentryCollection Sentries { get; }
Property Value
| Type | Description |
|---|---|
| SentryCollection |
SqlType
The kind of Sql command this object represents.
Declaration
public override SqlType SqlType { get; }
Property Value
| Type | Description |
|---|---|
| SqlType |
Overrides
Remarks
This object can be a delete, update or insert command.
TableInfo
Summary description for TableBase.
Declaration
public abstract TableInfo TableInfo { get; }
Property Value
| Type | Description |
|---|---|
| TableInfo |
Methods
BeginIgnoreSentryCheck()
Starts the process of ignoring sentry on the object implementing the interface on the current thread.
Declaration
public override IgnoreSentryCheck BeginIgnoreSentryCheck()
Returns
| Type | Description |
|---|---|
| IgnoreSentryCheck | Disposable object that calls EndIgnoreSentryCheck() on Dispose. |
Overrides
DeleteAsync()
Delete the row from the database.
Declaration
public virtual Task DeleteAsync()
Returns
| Type | Description |
|---|---|
| Task |
EndIgnoreSentryCheck()
Ends the process of ignoring sentry on the object implementing the interface on the current thread.
Declaration
public override void EndIgnoreSentryCheck()
Overrides
Exceptions
| Type | Condition |
|---|---|
| SoException | Thrown if Sentry is not ignored. |
GetFieldValue(FieldInfo)
Get the value of a field
Declaration
public override object GetFieldValue(FieldInfo field)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldInfo | field | Specification of a field |
Returns
| Type | Description |
|---|---|
| object | Field value, such as an int, DateTime, string ... |
Overrides
GetForeignKeyHelperAsync(CancellationToken)
Summary description for TableBase.
Declaration
public Task<RowForeignKeyHelper> GetForeignKeyHelperAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<RowForeignKeyHelper> |
GetKnownFields()
All the fields, including custom fields.
Declaration
public List<FieldInfo> GetKnownFields()
Returns
| Type | Description |
|---|---|
| List<FieldInfo> | List of all fields on the table, including custom fields. |
GetRelatedNestedPersist()
Get an enumerator for all related nested persist members.
Declaration
protected virtual IEnumerable<INestedPersist> GetRelatedNestedPersist()
Returns
| Type | Description |
|---|---|
| IEnumerable<INestedPersist> | Enumerator holding related nested persist members. |
InternalSetValue(SoField, object)
Summary description for TableBase.
Declaration
protected virtual void InternalSetValue(SoField fieldInfo, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| SoField | fieldInfo | |
| object | value |
InternalSetValue(int, object)
Summary description for TableBase.
Declaration
protected virtual void InternalSetValue(int fieldId, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | fieldId | |
| object | value |
InternalSetValue(string, object)
Summary description for TableBase.
Declaration
protected abstract void InternalSetValue(string fieldName, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fieldName | |
| object | value |
IsGhostField(FieldInfo)
Check if there is actually a valid value for the given field. If not, then this field is called a 'ghost'. This happens if a tablerow was 'fetched' but did not actually find its data in the database.
Declaration
public override bool IsGhostField(FieldInfo field)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldInfo | field | Specification of a field |
Returns
| Type | Description |
|---|---|
| bool | True if the field is a 'ghost', i.e., if it has NO valid known value |
Overrides
Remarks
In a TableRow object, we assume that either the whole row has been read, or none of it. Which field you're asking about is of less interest as long as it is one of ours.
Load(IdxBase, SoDataReader)
Populate a row based on a datareader.
Declaration
public void Load(IdxBase index, SoDataReader reader)
Parameters
| Type | Name | Description |
|---|---|---|
| IdxBase | index | Index for the table that holds this row |
| SoDataReader | reader | Reader to read data from. |
Load(SoDataReader, TableInfo)
Populate a row based on a datareader
Declaration
public void Load(SoDataReader reader, TableInfo tableInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| SoDataReader | reader | Reader to read data from. |
| TableInfo | tableInfo | Instance of TableInfo holding |
OnIdUpdateAsync()
Summary description for TableBase.
Declaration
protected virtual Task OnIdUpdateAsync()
Returns
| Type | Description |
|---|---|
| Task |
OnLoad(SoDataReader, TableInfo)
Called when data is read from the database, to fill the road with appropriate data.
Declaration
protected virtual void OnLoad(SoDataReader reader, TableInfo tableInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| SoDataReader | reader | SoDataReader holding the data returned from the database. |
| TableInfo | tableInfo | The TableInfo used for the SELECT statement. |
OnLoaded(IdxBase)
Called when data is loaded from the database, to do further processing.
Declaration
protected virtual void OnLoaded(IdxBase index)
Parameters
| Type | Name | Description |
|---|---|---|
| IdxBase | index | Index used to load data from the database |
OnPreIdUpdateAsync()
Allow for "fake id's" to be forced upon related objects.
Declaration
protected virtual Task OnPreIdUpdateAsync()
Returns
| Type | Description |
|---|---|
| Task |
Remarks
In order to figure out which objects taking part of the nested save operation that actually needs to be saved, this method allows for "fake id's" to be forced upon related objects. Upon receiving the "fake id", the objects receiving such an id can determine if they need to be persisted (e.g. saved) to the database. However, the fake id's forced upon related objects must be set to correct id's in the OnIdUpdate method taking place later in the save operation.
OnPrimaryKeyRequestAsync(PKContainer)
Summary description for TableBase.
Declaration
protected virtual Task OnPrimaryKeyRequestAsync(PKContainer pkContainer)
Parameters
| Type | Name | Description |
|---|---|---|
| PKContainer | pkContainer |
Returns
| Type | Description |
|---|---|
| Task |
Remarks
Check if the row is a INSERT or UPDATE command. If it is an INSERT command, an new primary key value is requested.
Validate to row.
OnPrimaryKeyUpdateAsync(PKContainer)
Summary description for TableBase.
Declaration
protected virtual Task OnPrimaryKeyUpdateAsync(PKContainer pkContainer)
Parameters
| Type | Name | Description |
|---|---|---|
| PKContainer | pkContainer |
Returns
| Type | Description |
|---|---|
| Task |
OnSaveAsync(BatchSave)
Summary description for TableBase.
Declaration
protected virtual Task OnSaveAsync(BatchSave batchSave)
Parameters
| Type | Name | Description |
|---|---|---|
| BatchSave | batchSave |
Returns
| Type | Description |
|---|---|
| Task |
OnSavedAsync(bool)
Summary description for TableBase.
Declaration
protected virtual Task OnSavedAsync(bool bSucceeded)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | bSucceeded |
Returns
| Type | Description |
|---|---|
| Task |
Reset()
Reset the changes made on the object.
Declaration
protected abstract void Reset()
Remarks
If the row is not persisted to the database (e.g. IsNew is true), all the values will be reset. If the row has been persisted to or loaded from the database, the properties will be set to those of the last persisted or loaded values.
RowLoad()
Load the row from the database, using the provided unique index.
Declaration
protected void RowLoad()
RowLoad(ITableRowLoadHandler)
Load the row from the database, using the provided unique index.
Declaration
protected void RowLoad(ITableRowLoadHandler handler)
Parameters
| Type | Name | Description |
|---|---|---|
| ITableRowLoadHandler | handler |
RowLoadAsync(ITableRowLoadHandler, CancellationToken)
Load the row from the database, using the provided unique index.
Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
protected Task RowLoadAsync(ITableRowLoadHandler handler, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| ITableRowLoadHandler | handler | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
SaveAsync()
Save all the contained objects to the database.
Declaration
public virtual Task SaveAsync()
Returns
| Type | Description |
|---|---|
| Task |
SetDefaultsAsync(DashboardTileDefinitionRow, string, CancellationToken)
Set default values for the appointment's main row, and for any udef fields it may have.
Declaration
public Task SetDefaultsAsync(DashboardTileDefinitionRow row, string entityName, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DashboardTileDefinitionRow | row | DashboardTileDefinitionRow |
| string | entityName | entity Name |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
SetDefaultsAsync(DefaulterStrategy, CancellationToken)
Set default values for the row.
Declaration
public abstract Task SetDefaultsAsync(DefaulterStrategy strategy, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DefaulterStrategy | strategy | Strategy used when applying default values; values depend on where we are in the Create/Fetch/Populate/Save cycle |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
SetDefaultsAsync(CancellationToken)
Set default values for the row.
Declaration
public Task SetDefaultsAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
SetDirty(int, object, object)
Force the object to be dirty.
Declaration
protected void SetDirty(int fieldId, object oldValue, object newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| int | fieldId | ID of the field that has changed |
| object | oldValue | The value of the field prior to change. |
| object | newValue | The value of the field after it was chaned. |
SetPrimaryKey(int)
Summary description for TableBase.
Declaration
protected abstract void SetPrimaryKey(int primaryKey)
Parameters
| Type | Name | Description |
|---|---|---|
| int | primaryKey |
SetRowAsNew()
Summary description for TableBase.
Declaration
public virtual void SetRowAsNew()
SetSaveOwner(INestedPersist)
Force the save operation to be handled by someone else.
Declaration
public virtual void SetSaveOwner(INestedPersist saveOwner)
Parameters
| Type | Name | Description |
|---|---|---|
| INestedPersist | saveOwner | The object to handle the save operation. |
Validate()
Validate the row, for saving to the database
Declaration
public virtual RowValidator Validate()
Returns
| Type | Description |
|---|---|
| RowValidator | The result of the validation. |
Validate(RowValidator)
Validate this row.
Declaration
public virtual void Validate(RowValidator rowValidator)
Parameters
| Type | Name | Description |
|---|---|---|
| RowValidator | rowValidator | RowValidator for inserting the result of the validation |
Events
OnElementIdUpdate
Event raised when the item receives a primary key
Declaration
public event OnIdUpdate OnElementIdUpdate
Event Type
| Type | Description |
|---|---|
| OnIdUpdate |
OnElementSaved
Event raised when the item is saved to the database.
Declaration
public event OnSaved OnElementSaved
Event Type
| Type | Description |
|---|---|
| OnSaved |