Show / Hide Table of Contents

Class EntityDetailsHelper<TParent, TChild>

Helper class for maintaining child items of type INestedPersist belonging to a parent item of type INestedPersist. Remember to call LoadChildItems from your subclass constructor

Inheritance
Object
NestedPersist
NestedPersistFacade
EntityDetailsHelper<TParent, TChild>
LinksHelper
Implements
INestedPersist
Inherited Members
NestedPersistFacade.OnPrimaryKeyRequest(PKContainer)
NestedPersistFacade.OnPrimaryKeyUpdate(PKContainer)
NestedPersistFacade.OnSave(BatchSave)
NestedPersist._saveOwner
NestedPersist._isSaving
NestedPersist.SetSaveOwner(INestedPersist)
NestedPersist.Save()
NestedPersist.INestedPersist.OnPreIdUpdate()
NestedPersist.INestedPersist.OnPrimaryKeyRequest(PKContainer)
NestedPersist.INestedPersist.OnPrimaryKeyUpdate(PKContainer)
NestedPersist.INestedPersist.OnIdUpdate()
NestedPersist.INestedPersist.OnSave(BatchSave)
NestedPersist.INestedPersist.OnSaved(Boolean)
NestedPersist.IsSaving
NestedPersist.IsDeleted
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 EntityDetailsHelper<TParent, TChild> : NestedPersistFacade, INestedPersist where TParent : class, INestedPersist where TChild : class, INestedPersist
Type Parameters
Name Description
TParent

Type of parent, normally a row or entity.

TChild

Type of child, normally a row or entity.

Constructors

EntityDetailsHelper(TParent)

Constructor called by the implementation

Declaration
protected EntityDetailsHelper(TParent parent)
Parameters
Type Name Description
TParent parent

Parent object owning the children.

Properties

Children

Get all the child items.

Declaration
protected TChild[] Children { get; }
Property Value
Type Description
TChild[]

IsDirty

Declaration
public override bool IsDirty { get; }
Property Value
Type Description
Boolean
Overrides
NestedPersistFacade.IsDirty

Items

Declaration
protected List<TChild> Items { get; }
Property Value
Type Description
List<TChild>

Parent

Get the parent object.

Declaration
protected TParent Parent { get; }
Property Value
Type Description
TParent

RemovedItems

Declaration
protected List<TChild> RemovedItems { get; }
Property Value
Type Description
List<TChild>

Methods

Add(TChild)

Add a child to the collection.

Declaration
protected TChild Add(TChild child)
Parameters
Type Name Description
TChild child

Instance of the child to add.

Returns
Type Description
TChild

The item actually added.

Remarks

Override IsSameChild(TChild, TChild) if a custom implementation is required for comparing two child items. This is used when checking if the child was previously removed and now can be re-added.

FindChildInItems(ref TChild)

Find a child in the list of items and return the found one. Note that IsSameChild(TChild, TChild) is called to determine equivalence, so that the found instance may be different from the one being looked for.

Declaration
protected bool FindChildInItems(ref TChild foundEquivalent)
Parameters
Type Name Description
TChild foundEquivalent

Child to search for, updated with the one actually found

Returns
Type Description
Boolean

True if there exists an equivalent child to the one searched for.

GetFacadingItems()

Declaration
protected override IEnumerable<INestedPersist> GetFacadingItems()
Returns
Type Description
IEnumerable<INestedPersist>
Overrides
NestedPersistFacade.GetFacadingItems()

hasChanged(TChild, TChild)

Declaration
protected virtual bool hasChanged(TChild child1, TChild child2)
Parameters
Type Name Description
TChild child1
TChild child2
Returns
Type Description
Boolean

IsSameChild(TChild, TChild)

Determine if two children are the same. This base implementation uses the == operator if the child type; override if you need different behaviour (see IsSameChild(RelationsRow, RelationsRow) for an example override).

Declaration
protected virtual bool IsSameChild(TChild child1, TChild child2)
Parameters
Type Name Description
TChild child1
TChild child2
Returns
Type Description
Boolean

LoadChildItems(TParent)

Declaration
public abstract void LoadChildItems(TParent parent)
Parameters
Type Name Description
TParent parent

OnChildIdUpdate(TParent, TChild, Boolean)

Declaration
protected abstract void OnChildIdUpdate(TParent parent, TChild child, bool isRemoved)
Parameters
Type Name Description
TParent parent
TChild child
Boolean isRemoved

OnChildPreIdUpdate(TParent, TChild, Boolean)

Declaration
protected abstract void OnChildPreIdUpdate(TParent parent, TChild child, bool isRemoved)
Parameters
Type Name Description
TParent parent
TChild child
Boolean isRemoved

OnIdUpdate()

Declaration
protected override void OnIdUpdate()
Overrides
NestedPersistFacade.OnIdUpdate()

OnParentIdUpdate(TParent)

Declaration
protected virtual void OnParentIdUpdate(TParent parent)
Parameters
Type Name Description
TParent parent

OnParentPreIdUpdate(TParent)

Declaration
protected virtual void OnParentPreIdUpdate(TParent parent)
Parameters
Type Name Description
TParent parent

OnPreIdUpdate()

Declaration
protected override void OnPreIdUpdate()
Overrides
NestedPersistFacade.OnPreIdUpdate()

OnSaved(Boolean)

Declaration
protected override void OnSaved(bool bSucceeded)
Parameters
Type Name Description
Boolean bSucceeded
Overrides
NestedPersistFacade.OnSaved(Boolean)

Remove(TChild)

Declaration
protected void Remove(TChild child)
Parameters
Type Name Description
TChild child

SetChildren(TChild[])

Set the desired new children collection. This method uses the virtual IsSameChild(TChild, TChild) to compare each incoming child with existing children, and determines children to be added, removed or left unchanged. It will only add children that are new according to IsSameChild regardless of whether the underlying TChild instances are the same. Existing children that are not in the new set are marked for deletion, but may be resurrected by a later SetChildren or AddChild call.

Declaration
protected void SetChildren(params TChild[] children)
Parameters
Type Name Description
TChild[] children

Children that should be the new set

Events

OnEntityDetailsHelperAdded

Declaration
public event EntityDetailsHelperModified<TParent, TChild> OnEntityDetailsHelperAdded
Event Type
Type Description
EntityDetailsHelperModified<TParent, TChild>

OnEntityDetailsHelperRemoved

Declaration
public event EntityDetailsHelperModified<TParent, TChild> OnEntityDetailsHelperRemoved
Event Type
Type Description
EntityDetailsHelperModified<TParent, TChild>

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