Class LinksHelper
Helper class for links management on entities
Inheritance
Implements
Inherited Members
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 |
|
Overrides
SourceTableId
Helper class for links management on entities
Declaration
protected short SourceTableId { get; }
Property Value
Type | Description |
---|---|
short |
Methods
AddLink(TableRowBase, string)
Adds a link relation to the entity. If the source does not match the LinkHelper source an exception is thrown.
Declaration
protected RelationsRow AddLink(TableRowBase targetEntityRow, string relationComment)
Parameters
Type | Name | Description |
---|---|---|
TableRowBase | targetEntityRow | The target/destination data row |
string | relationComment | Any relation comment |
Returns
Type | Description |
---|---|
RelationsRow | The saved RelationsRow or null if the target did not exist |
AddLink(TableInfo, int, string)
Adds a link relation to the entity. If the source does not match the LinkHelper source an exception is thrown.
Declaration
protected RelationsRow AddLink(TableInfo targetTableInfo, int targetEntityId, string relationComment)
Parameters
Type | Name | Description |
---|---|---|
TableInfo | targetTableInfo | The target/destination table info |
int | targetEntityId | The target/destination entity id |
string | relationComment | Any relation comment |
Returns
Type | Description |
---|---|
RelationsRow |
AddLink(short, int, string)
Helper class for links management on entities
Declaration
protected RelationsRow AddLink(short targetTableId, int targetEntityId, string relationComment)
Parameters
Type | Name | Description |
---|---|---|
short | targetTableId | |
int | targetEntityId | |
string | relationComment |
Returns
Type | Description |
---|---|
RelationsRow |
AddLinks(RelationsRows)
Adds link relations to the entity. If the source does not match the LinkHelper source an exception is thrown.
Declaration
public virtual RelationsRows AddLinks(RelationsRows relationsRows)
Parameters
Type | Name | Description |
---|---|---|
RelationsRows | relationsRows | Collection of Relation Rows to save |
Returns
Type | Description |
---|---|
RelationsRows | The saved RelationsRows |
AddSimilarLink(RelationsRow)
Add similar link
Declaration
public RelationsRow AddSimilarLink(RelationsRow relationsRow)
Parameters
Type | Name | Description |
---|---|---|
RelationsRow | relationsRow |
Returns
Type | Description |
---|---|
RelationsRow | The new link |
CopyTo(LinksHelper)
Remove all the links from the other LinksHelper, and create new links identical with this one.
Declaration
public void CopyTo(LinksHelper otherLinksHelper)
Parameters
Type | Name | Description |
---|---|---|
LinksHelper | otherLinksHelper | The links helper to apply the links on. |
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 |
DeleteSimilarLink(RelationsRow)
Delete similar link if it exists.
Declaration
public void DeleteSimilarLink(RelationsRow relationsRow)
Parameters
Type | Name | Description |
---|---|---|
RelationsRow | relationsRow | Relations row pointing to the item to remove link to. |
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 |
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
LoadChildItems(TableRowBase)
Load the Relations items, based on our (parent) table type and primary key
Declaration
public override void LoadChildItems(TableRowBase parent)
Parameters
Type | Name | Description |
---|---|---|
TableRowBase | parent | Parent on whose behalf we are loading relations |
Overrides
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
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
SetLinks(RelationsRows)
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 void SetLinks(RelationsRows relationsRows)
Parameters
Type | Name | Description |
---|---|---|
RelationsRows | relationsRows | Collection of Relation Rows to save |
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 |