Show / Hide Table of Contents

Class LinksHelper

Helper class for links management on entities

Inheritance
object
NestedPersist
NestedPersistFacade
EntityDetailsHelper<TableRowBase, RelationsRow>
LinksHelper
ActivityLinksHelper
Implements
INestedPersist
Inherited Members
EntityDetailsHelper<TableRowBase, RelationsRow>.Add(RelationsRow)
EntityDetailsHelper<TableRowBase, RelationsRow>.Remove(RelationsRow)
EntityDetailsHelper<TableRowBase, RelationsRow>.Edit(RelationsRow)
EntityDetailsHelper<TableRowBase, RelationsRow>.SetChildren(params RelationsRow[])
EntityDetailsHelper<TableRowBase, RelationsRow>.FindChildInItems(ref RelationsRow)
EntityDetailsHelper<TableRowBase, RelationsRow>.IsSameChild(RelationsRow, RelationsRow)
EntityDetailsHelper<TableRowBase, RelationsRow>.hasChanged(RelationsRow, RelationsRow)
EntityDetailsHelper<TableRowBase, RelationsRow>.GetFacadingItems()
EntityDetailsHelper<TableRowBase, RelationsRow>.OnPreIdUpdateAsync()
EntityDetailsHelper<TableRowBase, RelationsRow>.OnIdUpdateAsync()
EntityDetailsHelper<TableRowBase, RelationsRow>.OnSavedAsync(bool)
EntityDetailsHelper<TableRowBase, RelationsRow>.OnParentPreIdUpdate(TableRowBase)
EntityDetailsHelper<TableRowBase, RelationsRow>.OnChildPreIdUpdate(TableRowBase, RelationsRow, bool)
EntityDetailsHelper<TableRowBase, RelationsRow>.OnParentIdUpdate(TableRowBase)
EntityDetailsHelper<TableRowBase, RelationsRow>.OnChildIdUpdate(TableRowBase, RelationsRow, bool)
EntityDetailsHelper<TableRowBase, RelationsRow>.LoadChildItemsAsync(TableRowBase, CancellationToken)
EntityDetailsHelper<TableRowBase, RelationsRow>.Items
EntityDetailsHelper<TableRowBase, RelationsRow>.RemovedItems
EntityDetailsHelper<TableRowBase, RelationsRow>.Parent
EntityDetailsHelper<TableRowBase, RelationsRow>.Children
EntityDetailsHelper<TableRowBase, RelationsRow>.IsDirty
EntityDetailsHelper<TableRowBase, RelationsRow>.OnEntityDetailsHelperAdded
EntityDetailsHelper<TableRowBase, RelationsRow>.OnEntityDetailsHelperRemoved
EntityDetailsHelper<TableRowBase, RelationsRow>.OnEntityDetailsHelperEdited
NestedPersistFacade.OnPreIdUpdateAsync()
NestedPersistFacade.OnPrimaryKeyRequestAsync(PKContainer)
NestedPersistFacade.OnPrimaryKeyUpdateAsync(PKContainer)
NestedPersistFacade.OnIdUpdateAsync()
NestedPersistFacade.OnSaveAsync(BatchSave)
NestedPersistFacade.OnSavedAsync(bool)
NestedPersistFacade.GetFacadingItems()
NestedPersistFacade.IsDirty
NestedPersist._saveOwner
NestedPersist._isSaving
NestedPersist.SetSaveOwner(INestedPersist)
NestedPersist.SaveAsync()
NestedPersist.IsSaving
NestedPersist.IsMarkedForDelete
NestedPersist.OnElementSaved
NestedPersist.OnElementIdUpdate
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice.CRM.Entities
Assembly: SoDataBase.dll
Syntax
public abstract class LinksHelper : EntityDetailsHelper<TableRowBase, RelationsRow>, INestedPersist

Constructors

LinksHelper(TableRowBase)

Default constructor setting the link source info

Declaration
protected LinksHelper(TableRowBase sourceEntityRow)
Parameters
Type Name Description
TableRowBase sourceEntityRow

The row object of the source entity

Properties

IsDeleted

Gets a value indicating whether this instance is deleted.

Declaration
public override bool IsDeleted { get; }
Property Value
Type Description
bool

true if this instance is deleted; otherwise, false.

Overrides
NestedPersist.IsDeleted

SourceTableId

Helper class for links management on entities

Declaration
protected short SourceTableId { get; }
Property Value
Type Description
short

Methods

AddLinkAsync(TableRowBase, string, CancellationToken)

Adds a link relation to the entity. If the source does not match the LinkHelper source an exception is thrown.

Declaration
protected Task<RelationsRow> AddLinkAsync(TableRowBase targetEntityRow, string relationComment, CancellationToken cancellationToken = default)
Parameters
Type Name Description
TableRowBase targetEntityRow

The target/destination data row

string relationComment

Any relation comment

CancellationToken cancellationToken
Returns
Type Description
Task<RelationsRow>

The saved RelationsRow or null if the target did not exist

AddLinkAsync(TableInfo, int, string, CancellationToken)

Adds a link relation to the entity. If the source does not match the LinkHelper source an exception is thrown.

Declaration
protected Task<RelationsRow> AddLinkAsync(TableInfo targetTableInfo, int targetEntityId, string relationComment, CancellationToken cancellationToken = default)
Parameters
Type Name Description
TableInfo targetTableInfo

The target/destination table info

int targetEntityId

The target/destination entity id

string relationComment

Any relation comment

CancellationToken cancellationToken
Returns
Type Description
Task<RelationsRow>

AddLinkAsync(short, int, string, CancellationToken)

Helper class for links management on entities

Declaration
protected Task<RelationsRow> AddLinkAsync(short targetTableId, int targetEntityId, string relationComment, CancellationToken cancellationToken = default)
Parameters
Type Name Description
short targetTableId
int targetEntityId
string relationComment
CancellationToken cancellationToken
Returns
Type Description
Task<RelationsRow>

AddLinksAsync(RelationsRows, CancellationToken)

Adds link relations to the entity. If the source does not match the LinkHelper source an exception is thrown.

Declaration
public virtual Task<RelationsRows> AddLinksAsync(RelationsRows relationsRows, CancellationToken cancellationToken = default)
Parameters
Type Name Description
RelationsRows relationsRows

Collection of Relation Rows to save

CancellationToken cancellationToken
Returns
Type Description
Task<RelationsRows>

The saved RelationsRows

AddSimilarLinkAsync(RelationsRow, CancellationToken)

Add similar link

Declaration
public Task<RelationsRow> AddSimilarLinkAsync(RelationsRow relationsRow, CancellationToken cancellationToken = default)
Parameters
Type Name Description
RelationsRow relationsRow
CancellationToken cancellationToken
Returns
Type Description
Task<RelationsRow>

The new link

CopyToAsync(LinksHelper, CancellationToken)

Remove all the links from the other LinksHelper, and create new links identical with this one.

Declaration
public Task CopyToAsync(LinksHelper otherLinksHelper, CancellationToken cancellationToken = default)
Parameters
Type Name Description
LinksHelper otherLinksHelper

The links helper to apply the links on.

CancellationToken cancellationToken
Returns
Type Description
Task

DeleteLinks(params int[])

Deletes the links if the link belongs to the source entity

Declaration
public virtual void DeleteLinks(params int[] linkIds)
Parameters
Type Name Description
int[] linkIds

DeleteSimilarLinkAsync(RelationsRow, CancellationToken)

Delete similar link if it exists.

Declaration
public Task DeleteSimilarLinkAsync(RelationsRow relationsRow, CancellationToken cancellationToken = default)
Parameters
Type Name Description
RelationsRow relationsRow

Relations row pointing to the item to remove link to.

CancellationToken cancellationToken
Returns
Type Description
Task

EditSimilarLinkAsync(RelationsRow, CancellationToken)

Edit similar link if it exists.

Declaration
public Task<RelationsRow> EditSimilarLinkAsync(RelationsRow relationsRow, CancellationToken cancellationToken = default)
Parameters
Type Name Description
RelationsRow relationsRow

Relations row pointing to the item to edit.

CancellationToken cancellationToken
Returns
Type Description
Task<RelationsRow>

GetLinks()

Gets all links (Relation rows) that belong to the source entity

Declaration
public RelationsRows GetLinks()
Returns
Type Description
RelationsRows

All links (Relation rows) that belong to the source entity

InitializeAsync(TableRowBase)

Helper class for links management on entities

Declaration
protected Task InitializeAsync(TableRowBase sourceEntityRow)
Parameters
Type Name Description
TableRowBase sourceEntityRow
Returns
Type Description
Task

IsSameChild(RelationsRow, RelationsRow)

Two links records are equivalent if their sources and destinations match, and they refer to the same relation definition

Declaration
protected override bool IsSameChild(RelationsRow child1, RelationsRow child2)
Parameters
Type Name Description
RelationsRow child1
RelationsRow child2
Returns
Type Description
bool
Overrides
EntityDetailsHelper<TableRowBase, RelationsRow>.IsSameChild(RelationsRow, RelationsRow)

LoadChildItemsAsync(TableRowBase, CancellationToken)

Load the Relations items, based on our (parent) table type and primary key

Declaration
public override Task LoadChildItemsAsync(TableRowBase parent, CancellationToken cancellationToken = default)
Parameters
Type Name Description
TableRowBase parent

Parent on whose behalf we are loading relations

CancellationToken cancellationToken
Returns
Type Description
Task
Overrides
EntityDetailsHelper<TableRowBase, RelationsRow>.LoadChildItemsAsync(TableRowBase, CancellationToken)
Remarks

To support two-way links (i.e., a row in the relations table should be present in the Links collections of both the source AND the destination entity), we load in two stages. First stage is the normal left-to-right; second stage is right-to-left. In the second stage, we set the RelationsRowImplementation.SuperOffice.CRM.Rows.Implementation.RelationsRowImplementation.IsRightToLeft flag, which causes all access to the Source and Destination properties to be mirrored. In this way, we make the right-to-left links appear as though they were ordinary left-to-right links.

OnChildIdUpdate(TableRowBase, RelationsRow, bool)

Helper class for links management on entities

Declaration
protected override void OnChildIdUpdate(TableRowBase parent, RelationsRow child, bool isRemoved)
Parameters
Type Name Description
TableRowBase parent
RelationsRow child
bool isRemoved
Overrides
EntityDetailsHelper<TableRowBase, RelationsRow>.OnChildIdUpdate(TableRowBase, RelationsRow, bool)

OnChildPreIdUpdate(TableRowBase, RelationsRow, bool)

Helper class for links management on entities

Declaration
protected override void OnChildPreIdUpdate(TableRowBase parent, RelationsRow child, bool isRemoved)
Parameters
Type Name Description
TableRowBase parent
RelationsRow child
bool isRemoved
Overrides
EntityDetailsHelper<TableRowBase, RelationsRow>.OnChildPreIdUpdate(TableRowBase, RelationsRow, bool)

SetLinksAsync(RelationsRows, CancellationToken)

Sets link relations to the entity. Existing relations are deleted or updated If the source does not match the LinkHelper source an exception is thrown.

Declaration
public virtual Task SetLinksAsync(RelationsRows relationsRows, CancellationToken cancellationToken = default)
Parameters
Type Name Description
RelationsRows relationsRows

Collection of Relation Rows to save

CancellationToken cancellationToken
Returns
Type Description
Task

The saved RelationsRows

hasChanged(RelationsRow, RelationsRow)

Helper class for links management on entities

Declaration
protected override bool hasChanged(RelationsRow child1, RelationsRow child2)
Parameters
Type Name Description
RelationsRow child1
RelationsRow child2
Returns
Type Description
bool
Overrides
EntityDetailsHelper<TableRowBase, RelationsRow>.hasChanged(RelationsRow, RelationsRow)

Implements

INestedPersist

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top