1. Stylelabs.M.Sdk.Models.Base

Class RelationBase

Base class for relations.

Inheritance

object

MemberBase

RelationBase

ChildRelationBase

Implements

IRelation

IMember

IDirtyTracking

Inherited Members

MemberBase.Name

MemberBase.IsTracking

MemberBase.IsDirty

MemberBase.StartTracking()

MemberBase.MarkClean()

Namespace: StylelabsStylelabs.MSdkStylelabs.M.Sdk.ModelsBase

Assembly: Stylelabs.M.Sdk.dll

Syntax

public abstract class RelationBase : MemberBase, IRelation, IMember, IDirtyTracking

Constructors

RelationBase(IMClient, string, IDictionary<long, IDictionary<string, JToken>>)

Initializes a new instance of the RelationBase class.

Declaration

protected RelationBase(IMClient client, string name, IDictionary<long, IDictionary<string, JToken>> properties = null)

Parameters

TypeNameDescription
IMClientclientThe IMClient instance.
stringnameThe name of the relation.
IDictionary<, >longIDictionary<, >stringJTokenpropertiesThe properties of the linked entity.

RelationBase(string, IDictionary<long, IDictionary<string, JToken>>)

Initializes a new instance of the RelationBase class.

Declaration

protected RelationBase(string name, IDictionary<long, IDictionary<string, JToken>> properties = null)

Parameters

TypeNameDescription
stringnameThe name of the relation.
IDictionary<, >longIDictionary<, >stringJTokenpropertiesThe properties of the linked entity.

Properties

DefinitionType

Gets the definition type.

Declaration

public override MemberDefinitionType DefinitionType { get; }

Property Value

TypeDescription
MemberDefinitionType

Overrides

MemberBase.DefinitionType

Properties

Gets the properties of the linked entity.

Declaration

public IDictionary<long, IDictionary<string, JToken>> Properties { get; }

Property Value

TypeDescription
IDictionary<, >longIDictionary<, >stringJToken

Gets the role of this instance in the relation.

Declaration

public abstract RelationRole Role { get; }

Property Value

TypeDescription
RelationRole

Methods

Clear()

Clears the value(s) of the relation.

Declaration

public abstract void Clear()

GetIds()

This utility method allows getting the value of any type of relation.

In case of an IToManyRelation the result will contain all ids on the relation.

In case of an IToOneRelation the list can contain 1 id (maximum) if an id was set on the relation. If no id was set on the relation, an empty list is returned.

Declaration

public abstract IList<long> GetIds()

Returns

TypeDescription
IList<>longA list of ids (never null).

GetTypeName()

Gets the name of the relation type.

Declaration

protected abstract string GetTypeName()

Returns

TypeDescription
stringThe name of the type.

SetIdentifiersAsync(IEnumerable)

Sets the ids on the relations values based on the given identifiers.

In case of an IToManyRelation, the list of ids will be set on the relation.

In case of an IToOneRelation, identifiers can have at most one value. If the list is empty then the value will be set to null.

Declaration

public Task SetIdentifiersAsync(IEnumerable<string> identifiers)

Parameters

TypeNameDescription
IEnumerable<>stringidentifiersIdentifiers.

Returns

TypeDescription
TaskA representing the asynchronous operation.

SetIds(IEnumerable)

Sets the ids on the relations values. The values should be strictly positive.

In case of an IToManyRelation, the list of ids will be set on the relation.

In case of an IToOneRelation, ids can have at most one value. If the list is empty then the value will be set to null.

Declaration

public abstract void SetIds(IEnumerable<long> ids)

Parameters

TypeNameDescription
IEnumerable<>longidsIds.

Implements

IRelation

IMember

IDirtyTracking

If you have suggestions for improving this article, let us know!