SaaS CMS has officially launched! Learn more now.

Class Relation

Abstract base class for relations describing catalog structure.

Inheritance
System.Object
Relation
Implements
EPiServer.Data.Entity.IReadOnly<Relation>
EPiServer.Data.Entity.IReadOnly
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Commerce.Catalog.Linking
Assembly: EPiServer.Business.Commerce.dll
Version: 11.8.3
Syntax
public abstract class Relation : IReadOnly<Relation>, IReadOnly

Constructors

Relation()

Declaration
protected Relation()

Properties

AllowedChildTypes

Gets the types allowed for Child.

Declaration
protected abstract CatalogContentType[] AllowedChildTypes { get; }
Property Value
Type Description
CatalogContentType[]

AllowedParentTypes

Gets the types allowed for Parent.

Declaration
protected abstract CatalogContentType[] AllowedParentTypes { get; }
Property Value
Type Description
CatalogContentType[]

Child

The child catalog content in the parent-child relation.

Declaration
public ContentReference Child { get; set; }
Property Value
Type Description
EPiServer.Core.ContentReference

The EPiServer.Core.ContentReference of the catalog content (CatalogContentBase) that is the child in the relation.

IsReadOnly

Indicates whether the current object instance is read-only.

Declaration
public bool IsReadOnly { get; }
Property Value
Type Description
System.Boolean

Parent

The parent catalog content in the parent-child relation.

Declaration
public ContentReference Parent { get; set; }
Property Value
Type Description
EPiServer.Core.ContentReference

The EPiServer.Core.ContentReference of the catalog content (CatalogContentBase) that is the parent in the relation.

SortOrder

Gets the sort order.

Declaration
public int SortOrder { get; set; }
Property Value
Type Description
System.Int32

The sort order used when sorting all child objects of the same type with the same parent.

Source

Gets or sets the source of the relation (the item that has the relation). For NodeRelation this is the categorized item (entry or subcategory). For ProductVariation, PackageEntry and Parent this is the product/bundle/package itself.

Declaration
[Obsolete("This property is no longer used, use Parent/Child instead. Will remain at least until May 2018.")]
public ContentReference Source { get; set; }
Property Value
Type Description
EPiServer.Core.ContentReference
Remarks

Using Child and Source is recommended over using Target and BundleEntry as the parent-child analogy of relations is less abstract and in most cases easier to understand than source-target.

SourceAccessor

Backing implementation for Source

Declaration
protected abstract ContentReference SourceAccessor { get; set; }
Property Value
Type Description
EPiServer.Core.ContentReference

Target

Gets or sets the target of the relation (the item we're relating to). For NodeRelation this is the category (parent). For ProductVariation this is the variant. For BundleEntry and PackageEntry this is the entry included in the bundle/package.

Declaration
[Obsolete("This property is no longer used, use Parent/Child instead. Will remain at least until May 2018.")]
public ContentReference Target { get; set; }
Property Value
Type Description
EPiServer.Core.ContentReference
Remarks

Using Parent and Child is recommended over using Source and Target as the parent-child analogy of relations is less abstract and in most cases easier to understand than source-target.

TargetAccessor

Backing implementation for Target

Declaration
protected abstract ContentReference TargetAccessor { get; set; }
Property Value
Type Description
EPiServer.Core.ContentReference

Methods

CreateWritableClone()

Creates a writable copy of the current object.

Declaration
public Relation CreateWritableClone()
Returns
Type Description
Relation

A writable copy of the current object.

Remarks

The cloning is a deep-copy.

CreateWritableClone<T>()

Creates a writable copy of the current object.

Declaration
public T CreateWritableClone<T>()
    where T : Relation
Returns
Type Description
T

A writable copy of the current object.

Type Parameters
Name Description
T

The type to clone to.

Remarks

The cloning is a deep-copy.

CreateWritableCloneImplementation()

Implements the deep clone. Override to add any operations not handled by the base implementation (which includes a shallow copy by MemberwiseClone).

Declaration
protected virtual Relation CreateWritableCloneImplementation()
Returns
Type Description
Relation

A cloned instance in read-write mode.

MakeReadOnly()

Changes the object instance into a read-only object.

Declaration
public void MakeReadOnly()
Remarks

After calling this method, any attempt to change the object instance or any contained object will generate a System.NotSupportedException. I.e. the semantics is "deep read-only".

Note! After setting an object to read-only it is not possible to revert back to read-write mode. You will have to call the CreateWritableClone method to get a copy that can be modified.

ThrowIfReadOnly()

Calls EPiServer.Data.Validator.ValidateNotReadOnly(EPiServer.Data.Entity.IReadOnly) which throws an exception if the item is in read-only mode. Subtypes should call this before accepting any modification to the object.

Declaration
protected void ThrowIfReadOnly()

ValidateType(ReferenceConverter, ContentReference, String, CatalogContentType[])

Validates that a content reference points to a catalog content of one of the specified types.

Declaration
protected void ValidateType(ReferenceConverter referenceConverter, ContentReference contentLink, string propertyName, params CatalogContentType[] allowedTypes)
Parameters
Type Name Description
ReferenceConverter referenceConverter

The reference converter.

EPiServer.Core.ContentReference contentLink

The content link.

System.String propertyName

Name of the property.

CatalogContentType[] allowedTypes

The allowed types.

Exceptions
Type Condition
System.InvalidOperationException

Thrown if the reference is not of any of the allowed types.

Implements

EPiServer.Data.Entity.IReadOnly<>
EPiServer.Data.Entity.IReadOnly