Class MessageRow
Definition of a message, corresponding to the header of a protocol
Row Object for table 'Message'. Row objects correspond directly to database tables, and one
instance of a row object represents one row in the corresponding table in the database.
Inherited Members
Namespace: SuperOfficeCRMRows
Assembly: SoDataBase.dll
Syntax
public class MessageRow : TableRowBase, INestedPersist, ISoDataLookup, ISentryIgnorable
Remarks
Row objects can be created in several ways.
- Use the static CreateNew() method to create a new, empty object. After populating it with values, you call the SuperOffice.CRM.Data.TableRowBase.Save method and a corresponding row in the database is created, and the objects' primary key field updated. This is the preferred way to insert new rows into the database.
- You can create a (nested) MessageRow MessageRow.CustomSearch object to obtain a query pre-populated with the correct tableinfo and return fields. This query can be modified with restrictions, etc. Then, use the static GetFromCustomSearch(CustomSearch) method to apply the query to the database and obtain the result as a Row object. This is how you select existing rows from the database when you have a query that does not correspond to any of the existing database indexes.
- For each unique index defined for the table, there is a corresponding GetFromIdx method to make retrieving data via the indexes easy. Note that if you try to fetch a row that does not exist (for instance, by using the primary key index and specifying a primary key that does not exist in the database), you will get a Row object with the SuperOffice.CRM.Data.MessageRow.IsNew and SuperOffice.CRM.Data.MessageRow.IsDirty properties set to true. Such a Row object is called a 'ghost' and cannot be updated, saved or deleted. You can also get a ghost if the row does exist in the database, but the Sentry system denies Select rights to the row.
- Finally, if you have an SoDataReader that contains ALL the fields of the table, and you have the MessageTableInfo instance used in the query behind the reader, you can use the static GetFromReader(SoDataReader, MessageTableInfo) method to create a new row object from the reader and the table info. This is useful when you have a larger, more complex query, for instance one that joins a number of tables, and you wish to use Row objects to process the result set. If your result set corresponds to an entity, consider using the corresponding Entity layer object instead, since entities automatically handle ID allocation and mapping, rights, and other higher-level aspects.
Unique indexes on table Message are:
| Index fields | Nested index class name |
|---|
Constructors
MessageRow(MessageRowIdxBase)
Constructor for the class taking an index as argument. Definition of a message, corresponding to the header of a protocol
Declaration
protected MessageRow(MessageRow.MessageRowIdxBase idx)
Parameters
| Type | Name | Description |
|---|---|---|
| MessageRowMessageRowIdxBase | idx | The index representing a SELECT command to the database. |
Fields
_currentAssociateId
Current value, see property AssociateId.
Declaration
protected int _currentAssociateId
Field Value
| Type | Description |
|---|---|
| int |
_currentExpire
Current value, see property Expire.
Declaration
protected DateTime _currentExpire
Field Value
| Type | Description |
|---|---|
| DateTime |
_currentMarkdownMessage
Current value, see property MarkdownMessage.
Declaration
protected string _currentMarkdownMessage
Field Value
| Type | Description |
|---|---|
| string |
_currentMessageId
Current value, see property MessageId.
Declaration
protected int _currentMessageId
Field Value
| Type | Description |
|---|---|
| int |
_currentOnlineappId
Current value, see property OnlineappId.
Declaration
protected int _currentOnlineappId
Field Value
| Type | Description |
|---|---|
| int |
_currentRegistered
Current value, see property Registered.
Declaration
protected DateTime _currentRegistered
Field Value
| Type | Description |
|---|---|
| DateTime |
_currentRegisteredAssociateId
Current value, see property RegisteredAssociateId.
Declaration
protected int _currentRegisteredAssociateId
Field Value
| Type | Description |
|---|---|
| int |
_currentSystemMessageId
Current value, see property SystemMessageId.
Declaration
protected string _currentSystemMessageId
Field Value
| Type | Description |
|---|---|
| string |
_currentType
Current value, see property Type.
Declaration
protected SystemMessageType _currentType
Field Value
| Type | Description |
|---|---|
| SystemMessageType |
_currentUpdated
Current value, see property Updated.
Declaration
protected DateTime _currentUpdated
Field Value
| Type | Description |
|---|---|
| DateTime |
_currentUpdatedAssociateId
Current value, see property UpdatedAssociateId.
Declaration
protected int _currentUpdatedAssociateId
Field Value
| Type | Description |
|---|---|
| int |
_currentUpdatedCount
Current value, see property UpdatedCount.
Declaration
protected short _currentUpdatedCount
Field Value
| Type | Description |
|---|---|
| short |
_persistedAssociateId
Persisted value, see property AssociateId.
Declaration
protected int _persistedAssociateId
Field Value
| Type | Description |
|---|---|
| int |
_persistedExpire
Persisted value, see property Expire.
Declaration
protected DateTime _persistedExpire
Field Value
| Type | Description |
|---|---|
| DateTime |
_persistedMarkdownMessage
Persisted value, see property MarkdownMessage.
Declaration
protected string _persistedMarkdownMessage
Field Value
| Type | Description |
|---|---|
| string |
_persistedMessageId
Persisted value, see property MessageId.
Declaration
protected int _persistedMessageId
Field Value
| Type | Description |
|---|---|
| int |
_persistedOnlineappId
Persisted value, see property OnlineappId.
Declaration
protected int _persistedOnlineappId
Field Value
| Type | Description |
|---|---|
| int |
_persistedRegistered
Persisted value, see property Registered.
Declaration
protected DateTime _persistedRegistered
Field Value
| Type | Description |
|---|---|
| DateTime |
_persistedRegisteredAssociateId
Persisted value, see property RegisteredAssociateId.
Declaration
protected int _persistedRegisteredAssociateId
Field Value
| Type | Description |
|---|---|
| int |
_persistedSystemMessageId
Persisted value, see property SystemMessageId.
Declaration
protected string _persistedSystemMessageId
Field Value
| Type | Description |
|---|---|
| string |
_persistedType
Persisted value, see property Type.
Declaration
protected SystemMessageType _persistedType
Field Value
| Type | Description |
|---|---|
| SystemMessageType |
_persistedUpdated
Persisted value, see property Updated.
Declaration
protected DateTime _persistedUpdated
Field Value
| Type | Description |
|---|---|
| DateTime |
_persistedUpdatedAssociateId
Persisted value, see property UpdatedAssociateId.
Declaration
protected int _persistedUpdatedAssociateId
Field Value
| Type | Description |
|---|---|
| int |
_persistedUpdatedCount
Persisted value, see property UpdatedCount.
Declaration
protected short _persistedUpdatedCount
Field Value
| Type | Description |
|---|---|
| short |
Properties
AssociateId
.NET type: int. The associate that is the target of this message
Declaration
public virtual int AssociateId { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
Original type in dictionary: FK.
Setting this field to a new value will not affect the Sentry calculations and your rights
This field is not protected by the Sentry system, and can always be read
This field is not protected by the Sentry system, and can be written to unless other restrictions prevent it
Expire
.NET type: DateTime. The date and time the message expires in UTC
Declaration
public virtual DateTime Expire { get; set; }
Property Value
| Type | Description |
|---|---|
| DateTime |
Remarks
Original type in dictionary: UtcDateTime.
Setting this field to a new value will not affect the Sentry calculations and your rights
This field is not protected by the Sentry system, and can always be read
This field is not protected by the Sentry system, and can be written to unless other restrictions prevent it
InnerFieldValuePairs
The values of all the fields in the row.
The first field is the primary key.
The index of the value corresponds to the name
of the field returned from the Fields property.
Declaration
protected override ArgumentParameterCollection InnerFieldValuePairs { get; }
Property Value
| Type | Description |
|---|---|
| ArgumentParameterCollection |
Overrides
InnerPrimaryKey
The primary key needed to decide which specific row to alter with the current sql-command.
Declaration
protected override FieldInfo InnerPrimaryKey { get; }
Property Value
| Type | Description |
|---|---|
| FieldInfo |
Overrides
InnerPrimaryKeyValue
The actual value the primary key must have.
Declaration
protected override Parameter InnerPrimaryKeyValue { get; }
Property Value
| Type | Description |
|---|---|
| Parameter |
Overrides
IsDirty
Is the row dirty, e.g. been modified since the last time it was saved to the database.
Declaration
public override bool IsDirty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
IsNew
Is this object new, meaning that it does not exist in the database.
Declaration
public override bool IsNew { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
this[string]
Get or set a value based on the name of the field.
Declaration
public override 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. |
Overrides
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if the field is not known. |
MarkdownMessage
.NET type: string. Markdown message to be displayed to user
Declaration
public virtual string MarkdownMessage { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
Original type in dictionary: String[4001].
Setting this field to a new value will not affect the Sentry calculations and your rights
This field is not protected by the Sentry system, and can always be read
This field is not protected by the Sentry system, and can be written to unless other restrictions prevent it
MessageId
.NET type: int. Primary key
Declaration
public virtual int MessageId { get; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
Original type in dictionary: PK.
This field is the primary key and can only be read, never written.
This field is not protected by the Sentry system, and can always be read
MessageTableInfo
Get the MessageTableInfo object associated with the row.
Declaration
public MessageTableInfo MessageTableInfo { get; }
Property Value
| Type | Description |
|---|---|
| MessageTableInfo |
OnlineappId
.NET type: int. The online app that owns this message
Declaration
public virtual int OnlineappId { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
Original type in dictionary: FK.
Setting this field to a new value will not affect the Sentry calculations and your rights
This field is not protected by the Sentry system, and can always be read
This field is not protected by the Sentry system, and can be written to unless other restrictions prevent it
Registered
.NET type: DateTime. Registered when in UTC
Declaration
public virtual DateTime Registered { get; set; }
Property Value
| Type | Description |
|---|---|
| DateTime |
Remarks
Original type in dictionary: UtcDateTime.
Setting this field to a new value will not affect the Sentry calculations and your rights
This field is not protected by the Sentry system, and can always be read
This field is not protected by the Sentry system, and can be written to unless other restrictions prevent it
RegisteredAssociateId
.NET type: int. Registered by whom
Declaration
public virtual int RegisteredAssociateId { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
Original type in dictionary: FK.
Setting this field to a new value will not affect the Sentry calculations and your rights
This field is not protected by the Sentry system, and can always be read
This field is not protected by the Sentry system, and can be written to unless other restrictions prevent it
SystemMessageId
.NET type: string. Message identifier, used for message update or removal
Declaration
public virtual string SystemMessageId { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
Original type in dictionary: String[256].
Setting this field to a new value will not affect the Sentry calculations and your rights
This field is not protected by the Sentry system, and can always be read
This field is not protected by the Sentry system, and can be written to unless other restrictions prevent it
TableInfo
Get the TableInfo for the table.
Declaration
public override TableInfo TableInfo { get; }
Property Value
| Type | Description |
|---|---|
| TableInfo | The TableInfo for the table. |
Overrides
Type
.NET type: SystemMessageType. Type of message, example: info, warning, error
Declaration
public virtual SystemMessageType Type { get; set; }
Property Value
| Type | Description |
|---|---|
| SystemMessageType |
Remarks
Original type in dictionary: Enum.
Setting this field to a new value will not affect the Sentry calculations and your rights
This field is not protected by the Sentry system, and can always be read
This field is not protected by the Sentry system, and can be written to unless other restrictions prevent it
Updated
.NET type: DateTime. Last updated when in UTC
Declaration
public virtual DateTime Updated { get; set; }
Property Value
| Type | Description |
|---|---|
| DateTime |
Remarks
Original type in dictionary: UtcDateTime.
Setting this field to a new value will not affect the Sentry calculations and your rights
This field is not protected by the Sentry system, and can always be read
This field is not protected by the Sentry system, and can be written to unless other restrictions prevent it
UpdatedAssociateId
.NET type: int. Last updated by whom
Declaration
public virtual int UpdatedAssociateId { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
Original type in dictionary: FK.
Setting this field to a new value will not affect the Sentry calculations and your rights
This field is not protected by the Sentry system, and can always be read
This field is not protected by the Sentry system, and can be written to unless other restrictions prevent it
UpdatedCount
.NET type: short. Number of updates made to this record
Declaration
public virtual short UpdatedCount { get; set; }
Property Value
| Type | Description |
|---|---|
| short |
Remarks
Original type in dictionary: UShort.
Setting this field to a new value will not affect the Sentry calculations and your rights
This field is not protected by the Sentry system, and can always be read
This field is not protected by the Sentry system, and can be written to unless other restrictions prevent it
Methods
CreateNew()
Create a new instance of the MessageRow object. Definition of a message, corresponding to the header of a protocol
Declaration
public static MessageRow CreateNew()
Returns
| Type | Description |
|---|---|
| MessageRow | A new instance of the MessageRow object. |
GetFromCustomSearch(CustomSearch)
Create a new instance of the MessageRow object, and populate it with data from a custom search. If the search returns no results, an object with IsNew will be returned; if the result contains one row, an object representing that row will be returned. If the result contains more than one row, the first row will be used and the rest discarded (there is no way of detecting this situation).
Declaration
public static MessageRow GetFromCustomSearch(MessageRow.CustomSearch query)
Parameters
| Type | Name | Description |
|---|---|---|
| MessageRowCustomSearch | query | The custom search to execute against the database |
Returns
| Type | Description |
|---|---|
| MessageRow | A new instance of the MessageRow object, reflecting the result of the query. |
GetFromCustomSearchAsync(CustomSearch, CancellationToken)
Create a new instance of the MessageRow object, and populate it with data from a custom search. If the search returns no results, an object with IsNew will be returned; if the result contains one row, an object representing that row will be returned. If the result contains more than one row, the first row will be used and the rest discarded (there is no way of detecting this situation).
Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
public static Task<MessageRow> GetFromCustomSearchAsync(MessageRow.CustomSearch query, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MessageRowCustomSearch | query | The custom search to execute against the database |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| TaskMessageRow | A new instance of the MessageRow object, reflecting the result of the query. |
GetFromIdxAssociateIdSystemMessageIdOnlineappIdAsync(int, string, int, CancellationToken)
Create a new instance of the MessageRow object, by querying the database table via the index 'IAssociateIdSystemMessageIdOnlineapp_id'. This method is intended to make it easy to use efficient queries that match a database index.
Declaration
public static Task<MessageRow> GetFromIdxAssociateIdSystemMessageIdOnlineappIdAsync(int associateId, string systemMessageId, int onlineappId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | associateId | |
| string | systemMessageId | |
| int | onlineappId | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| TaskMessageRow | Row object that represents the result of the search. IsNew will be true if the query did not match any row in the table |
Remarks
This method represents one of the unique indexes on the Message table. Non-unique indexes have corresponding inner classes and methods in the MessageRows collection, since they may return more than one row.
GetFromIdxMessageIdAsync(int, CancellationToken)
Create a new instance of the MessageRow object, by querying the database table via the index 'IDXMessageId'. This method is intended to make it easy to use efficient queries that match a database index.
Declaration
public static Task<MessageRow> GetFromIdxMessageIdAsync(int messageId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | messageId | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| TaskMessageRow | Row object that represents the result of the search. IsNew will be true if the query did not match any row in the table |
Remarks
This method represents one of the unique indexes on the Message table. Non-unique indexes have corresponding inner classes and methods in the MessageRows collection, since they may return more than one row.
GetFromReader(SoDataReader, MessageTableInfo)
Create a new instance of the MessageRow object, and populate it with data from a reader/tableinfo. If the reader has DBNull as the current value of the primary key field, an unpopulated object with IsNew == true will be returned. If any fields are missing or one of the non-primary key fields is DBNull, an exception will be thrown. Definition of a message, corresponding to the header of a protocol
Declaration
public static MessageRow GetFromReader(SoDataReader reader, MessageTableInfo tableInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| SoDataReader | reader | SoDataReader positioned to a valid database row. |
| MessageTableInfo | tableInfo | MessageTableInfo instance used in the query that is the source of the reader. The fields used from the reader will be those owned by this tableinfo object. |
Returns
| Type | Description |
|---|---|
| MessageRow | A new instance of the MessageRow object. |
GetPersistedFieldValue(FieldInfo)
Get the persisted value of a field.
Declaration
public override object GetPersistedFieldValue(FieldInfo field)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldInfo | field | Specification of a field |
Returns
| Type | Description |
|---|---|
| object | Field value, such as an int, DateTime, string ... Null can be returned if the value is not known. |
Overrides
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if the field is not known. |
InternalSetValue(string, object)
Declaration
protected override void InternalSetValue(string fieldName, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fieldName | |
| object | value |
Overrides
IsPersistedFieldValueKnown(FieldInfo)
Check if the persisted value for a field is known.
Declaration
public override bool IsPersistedFieldValueKnown(FieldInfo field)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldInfo | field | Specification of a field |
Returns
| Type | Description |
|---|---|
| bool | True if the value is known and sentry permits read. |
Overrides
OnLoad(SoDataReader, TableInfo)
Fill the object with data returned from the database.
Declaration
protected override void OnLoad(SoDataReader reader, TableInfo tableInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| SoDataReader | reader | Object holding the data returned from the database. |
| TableInfo | tableInfo | The TableInfo used for the SELECT statement. |
Overrides
OnSaveAsync(BatchSave)
Add the object to the BatchSave list if it needs saving.
Declaration
protected override Task OnSaveAsync(BatchSave batchSave)
Parameters
| Type | Name | Description |
|---|---|---|
| BatchSave | batchSave | Collection of objects to be saved within the transaction. |
Returns
| Type | Description |
|---|---|
| Task |
Overrides
Remarks
Classes overriding this method should call it.
OnSavedAsync(bool)
Method called after the save operation has been performed.
Declaration
protected override Task OnSavedAsync(bool bSucceeded)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | bSucceeded | True if the save operation succeeded (e.g. transaction committed), or false if the save operation failed (e.g. transaction rolled back) |
Returns
| Type | Description |
|---|---|
| Task |
Overrides
Reset()
Reset the changes made on the object.
Declaration
protected override void Reset()
Overrides
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.
SetDefaultsAsync(DefaulterStrategy, CancellationToken)
Set default values for the row.
Declaration
public override 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 |
Overrides
SetPrimaryKey(int)
Set the primary key for the row.
Declaration
protected override void SetPrimaryKey(int primaryKey)
Parameters
| Type | Name | Description |
|---|---|---|
| int | primaryKey | The new primary key for the row. |
Overrides
SetRowAsNew()
Declaration
public override void SetRowAsNew()
Overrides
ToString()
ToString method intended for debugging, returns a string that displays the object type, new/dirty status, primary key and the string fields
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
Validate(RowValidator)
Validate this row.
Declaration
public override void Validate(RowValidator rowValidator)
Parameters
| Type | Name | Description |
|---|---|---|
| RowValidator | rowValidator | RowValidator for inserting the result of the validation |