Class RowForeignKeyHelper
Implements
Inherited Members
Namespace: SuperOffice.CRM.Rows.Util
Assembly: SoDataBase.dll
Syntax
public class RowForeignKeyHelper : NestedPersistFacade, INestedPersist
Properties
IsDeleted
This object do not support full delete. ForeignKeys need to be deleted individually
Declaration
public override bool IsDeleted { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
IsDirty
Do we have any changes
Declaration
public override bool IsDirty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
IsMarkedForDelete
This object do not support full delete. ForeignKeys need to be deleted individually
Declaration
public override bool IsMarkedForDelete { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
Methods
CreateAsync(TableRowBase, CancellationToken)
Declaration
public static Task<RowForeignKeyHelper> CreateAsync(TableRowBase sourceEntityRow, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| TableRowBase | sourceEntityRow | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<RowForeignKeyHelper> |
Get(int, string)
Get the value of a foreign key
Declaration
public string Get(int deviceId, string foreignKey)
Parameters
| Type | Name | Description |
|---|---|---|
| int | deviceId | Owner device identifier |
| string | foreignKey | Name of foreign key |
Returns
| Type | Description |
|---|---|
| string |
GetAll()
Get all associated foreign keys
Declaration
public IEnumerable<ForeignKeyRow> GetAll()
Returns
| Type | Description |
|---|---|
| IEnumerable<ForeignKeyRow> |
GetAllKeys(int)
Get all associated keys for one device
Declaration
public string[] GetAllKeys(int deviceId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | deviceId |
Returns
| Type | Description |
|---|---|
| string[] | A string array containing the keys |
GetFacadingItems()
Implement this method to expose items that needs to be persisted.
Declaration
protected override IEnumerable<INestedPersist> GetFacadingItems()
Returns
| Type | Description |
|---|---|
| IEnumerable<INestedPersist> | Collection of items that needs to be persisted. |
Overrides
GetForeignAppRowAsync(string, CancellationToken)
Get a foreign app row from the database. If the row is not found, one is created
Declaration
public static Task<ForeignAppRow> GetForeignAppRowAsync(string appName, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | appName | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ForeignAppRow> |
GetForeignDeviceRowAsync(int, string, string, CancellationToken)
Get a foreign device row from the database. If the row is not found, one is created
Declaration
public static Task<ForeignDeviceRow> GetForeignDeviceRowAsync(int foreignAppId, string deviceName, string deviceId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | foreignAppId | Id of "parent" foreign app row |
| string | deviceName | Name of device |
| string | deviceId | Device id |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ForeignDeviceRow> |
MergeValue(params string[])
Take a string splitted with SplitValue(string) and merge it back to a long string.
Declaration
public static string MergeValue(params string[] valueParts)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | valueParts | Fragments to be joined into one part. |
Returns
| Type | Description |
|---|---|
| string | Long string merged back from its' individual parts. |
Remarks
The current implementation does not address trailing white space, but future implementations will.
See Also
OnIdUpdateAsync()
Update related objects with correct id's to make sure that relations are consistent before saving to the database.
Declaration
protected override Task OnIdUpdateAsync()
Returns
| Type | Description |
|---|---|
| Task |
Overrides
OnPreIdUpdateAsync()
Allow for "fake id's" to be forced upon related objects.
Declaration
protected override Task OnPreIdUpdateAsync()
Returns
| Type | Description |
|---|---|
| Task |
Overrides
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 needs 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.
OnPrimaryKeyUpdateAsync(PKContainer)
Update primary key.
Declaration
protected override Task OnPrimaryKeyUpdateAsync(PKContainer pkContainer)
Parameters
| Type | Name | Description |
|---|---|---|
| PKContainer | pkContainer | Collection of objects getting a primary key. |
Returns
| Type | Description |
|---|---|
| Task |
Overrides
OnSaveAsync(BatchSave)
Add the object to the collection of objects that are to be saved within the transaction.
Declaration
protected override Task OnSaveAsync(BatchSave batchSave)
Parameters
| Type | Name | Description |
|---|---|---|
| BatchSave | batchSave | An object holding all the objects that needs to be persisted. |
Returns
| Type | Description |
|---|---|
| Task |
Overrides
OnSavedAsync(bool)
Called after the save operation has completed. A boolean value is passed to notify whether or not the save operation succeeded. The complete save operation is rolled back if Save operation failed.
Declaration
protected override Task OnSavedAsync(bool bSucceeded)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | bSucceeded | True if the save operation succeeded and false if the save operation failed and rolled back. |
Returns
| Type | Description |
|---|---|
| Task |
Overrides
Remove(int, string)
Remove a foreign key
Declaration
public void Remove(int deviceId, string foreignKey)
Parameters
| Type | Name | Description |
|---|---|---|
| int | deviceId | |
| string | foreignKey |
Set(int, string, string)
Add/edit a foreignkey
Declaration
public void Set(int deviceId, string foreignKey, string foreignValue)
Parameters
| Type | Name | Description |
|---|---|---|
| int | deviceId | |
| string | foreignKey | |
| string | foreignValue |
SplitValue(string)
The filed in the database storing the foreign key values are limited, hence; long values needs to be splits in parts. Due to database issues with trailing white spaces, some additional logic needs to be performed.
Declaration
public static string[] SplitValue(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | Value in foreign key to be split into separate parts that fits into the database. |
Returns
| Type | Description |
|---|---|
| string[] | Value split into parts that fit into the database. |
Remarks
The current implementation does not address trailing white space, but future implementations will.