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
EntityDetailsHelper<TParent, TChild>
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
Declaration
protected TChild[] Children { get; }
Property Value
Type |
Description |
TChild[] |
|
IsDirty
Declaration
public override bool IsDirty { get; }
Property Value
Overrides
Items
Declaration
protected List<TChild> Items { get; }
Property Value
Type |
Description |
List<TChild> |
|
Parent
Declaration
protected TParent Parent { get; }
Property Value
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.
|
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
Overrides
hasChanged(TChild, TChild)
Declaration
protected virtual bool hasChanged(TChild child1, TChild child2)
Parameters
Type |
Name |
Description |
TChild |
child1 |
|
TChild |
child2 |
|
Returns
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
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
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
OnSaved(Boolean)
Declaration
protected override void OnSaved(bool bSucceeded)
Parameters
Type |
Name |
Description |
Boolean |
bSucceeded |
|
Overrides
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
OnEntityDetailsHelperRemoved
Declaration
public event EntityDetailsHelperModified<TParent, TChild> OnEntityDetailsHelperRemoved
Event Type
Implements
Extension Methods
EnumUtil.MapEnums<From, To>(From)