public override void UpdatedAllOrphan(TForeignEntity ForeignEntity)
        {
            TForeignKey foreignKey = foreignKeyManager.GetEntityKey(ForeignEntity);

            if (propRelated != null)
            {
                EntityUnique <TForeignEntity, TRelatedEntity> relatedUnique = getRUniq(ForeignEntity);

                TRelatedEntity RelatedEntity = orphanage.Count(foreignKey) == 1 ? orphanage.GetAllRelated(foreignKey).ToArray()[0] : default;

                if (!RelatedEntity.IsNull()) // orphanage.Count != 0
                {
                    if (!RelatedEntity.HasEditable() || RelatedEntity.HasBusy())
                    {
                        throw new EntityRelationManagerException($"[{this}] UpdatedAllOrphan Failed, {RelatedEntity} With {RelatedEntity.State} State Is Not Supported");
                    }

                    // UpdatedOrphan ....
                    setFRef(RelatedEntity, ForeignEntity);
                    OrphanageRemove(RelatedEntity, foreignKey);

                    relatedUnique.InternalSet(RelatedEntity);

                    RelatedEntity.State |= EntityState.Busy;

                    RelatedEntity.OnPropertyChanged(propForeignReference.Name);

                    RelatedEntity.State ^= EntityState.Busy;
                }
            }
            else
            {
                TRelatedEntity RelatedEntity = orphanage.Count(foreignKey) == 1 ? orphanage.GetAllRelated(foreignKey).ToArray()[0] : default;

                if (!RelatedEntity.IsNull()) // orphanage.Count != 0
                {
                    if (!RelatedEntity.HasEditable() || RelatedEntity.HasBusy())
                    {
                        throw new EntityRelationManagerException($"[{this}] UpdatedAllOrphan Failed, {RelatedEntity} With {RelatedEntity.State} State Is Not Supported");
                    }

                    // UpdatedOrphan ....
                    setFRef(RelatedEntity, ForeignEntity);
                    OrphanageRemove(RelatedEntity, foreignKey);

                    RelatedEntity.State |= EntityState.Busy;

                    RelatedEntity.OnPropertyChanged(propForeignReference.Name);

                    RelatedEntity.State ^= EntityState.Busy;
                }
            }
        }
        private protected override void RelatedRemove(TRelatedEntity RelatedEntity, TForeignEntity ForeignEntity)
        {
            if (propRelated != null)
            {
                EntityUnique <TForeignEntity, TRelatedEntity> relatedUnique = getRUniq(ForeignEntity);
#if Test || Test2
                if (relatedUnique == null)
                {
                    throw new TestException($"[{this}] RelatedRemove Failed, {ForeignEntity} {typeof(TForeignEntity).Name}.{propRelated.Name} Is Null");
                }
#endif
                relatedUnique.InternalSet(default(TRelatedEntity));
            }
        }
        public override void InitializeRelated(TForeignEntity ForeignEntity)
        {
            if (propRelated != null)
            {
                EntityUnique <TForeignEntity, TRelatedEntity> relatedUnique = getRUniq(ForeignEntity);

                if (relatedUnique == null)
                {
                    throw new EntityRelationManagerException($"[{this}] InitializeRelated Failed, {ForeignEntity} {typeof(TForeignEntity).Name}.{propRelated.Name} Is Null");
                }

                relatedUnique.Initialize(ForeignEntity, this);
            }
        }
        public override void ResetRelated(TForeignEntity ForeignEntity)
        {
            if (propRelated != null)
            {
                EntityUnique <TForeignEntity, TRelatedEntity> relatedUnique = getRUniq(ForeignEntity);
#if Test || Test2
                if (relatedUnique == null)
                {
                    throw new TestException($"[{this}] ResetRelated Failed, {ForeignEntity} {typeof(TForeignEntity).Name}.{propRelated.Name} Is Null");
                }
#endif
                relatedUnique.Reset();
            }
        }
        public override void RestoreAllRelated(TForeignEntity ForeignEntity)
        {
            TForeignKey?foreignKey = foreignKeyManager.GetEntityKey(ForeignEntity);

            if (propRelated != null)
            {
                EntityUnique <TForeignEntity, TRelatedEntity> relatedUnique = getRUniq(ForeignEntity);

                TRelatedEntity RelatedEntity = relatedUnique.Entity;

                if (!RelatedEntity.IsNull())
                {
                    UpdateUniqueConstraint(foreignKey, getFKey(RelatedEntity));

                    setFKey(RelatedEntity, foreignKey);

                    RelatedEntity.State |= EntityState.Busy;

                    RelatedEntity.OnPropertyChanged(propForeignKey.Name);
                    RelatedEntity.OnPropertyChanged(propForeignReference.Name);

                    RelatedEntity.State ^= EntityState.Busy;
                }
            }
            else
            {
                foreach (TRelatedEntity RelatedEntity in relatedEntitySet)
                {
                    TForeignEntity foreignEntity = getFRef(RelatedEntity);

                    if (foreignEntity == ForeignEntity)
                    {
                        UpdateUniqueConstraint(foreignKey, getFKey(RelatedEntity));

                        setFKey(RelatedEntity, foreignKey);

                        RelatedEntity.State |= EntityState.Busy;

                        RelatedEntity.OnPropertyChanged(propForeignKey.Name);
                        RelatedEntity.OnPropertyChanged(propForeignReference.Name);

                        RelatedEntity.State ^= EntityState.Busy;

                        break;
                    }
                }
            }
        }
        public override void NotifyAllRelated(TForeignEntity ForeignEntity)
        {
            if (propRelated != null)
            {
                EntityUnique <TForeignEntity, TRelatedEntity> relatedUnique = getRUniq(ForeignEntity);

                TRelatedEntity RelatedEntity = relatedUnique.Entity;

                if (!RelatedEntity.IsNull())
                {
                    if (!RelatedEntity.HasEditable() || RelatedEntity.HasBusy())
                    {
                        throw new EntityRelationManagerException($"[{this}] NotifyAllRelated Failed, {RelatedEntity} With {RelatedEntity.State} State Is Not Supported");
                    }

                    RelatedEntity.State |= EntityState.Busy;

                    RelatedEntity.OnPropertyChanged(propForeignReference.Name);

                    RelatedEntity.State ^= EntityState.Busy;
                }
            }
            else
            {
                foreach (TRelatedEntity RelatedEntity in relatedEntitySet)
                {
                    TForeignEntity foreignEntity = getFRef(RelatedEntity);

                    if (foreignEntity == ForeignEntity)
                    {
                        if (!RelatedEntity.HasEditable() || RelatedEntity.HasBusy())
                        {
                            throw new EntityRelationManagerException($"[{this}] NotifyAllRelated Failed, {RelatedEntity} With {RelatedEntity.State} State Is Not Supported");
                        }

                        RelatedEntity.State |= EntityState.Busy;

                        RelatedEntity.OnPropertyChanged(propForeignReference.Name);

                        RelatedEntity.State ^= EntityState.Busy;

                        break;
                    }
                }
            }
        }
        public override bool IsRelated(TForeignEntity ForeignEntity)
        {
            if (propRelated != null)
            {
                EntityUnique <TForeignEntity, TRelatedEntity> relatedUnique = getRUniq(ForeignEntity);
#if Test || Test2
                if (relatedUnique == null)
                {
                    throw new TestException($"[{this}] IsRelated Failed, {ForeignEntity} {typeof(TForeignEntity).Name}.{propRelated.Name} Is Null");
                }
#endif
                return(!relatedUnique.Entity.IsNull());
            }
            else
            {
                foreach (TRelatedEntity RelatedEntity in relatedKeyManager)
                {
                    if (RelatedEntity.HasBusy())
                    {
                        throw new EntityRelationManagerException($"[{this}] IsRelated Failed, {ForeignEntity} Cannot Be Verified {RelatedEntity} Is Related, Because It's State Is {RelatedEntity.State}");
                    }

                    if (RelatedEntity.IsDeleted())
                    {
                        continue;
                    }

                    TForeignEntity foreignEntity = getFRef(RelatedEntity);

                    if (foreignEntity == ForeignEntity)
                    {
                        return(true);
                    }
                }

                return(false);
            }
        }
        public override void UpdatedAllRelated(TForeignEntity ForeignEntity)
        {
            TForeignKey?foreignKey = foreignKeyManager.GetEntityKey(ForeignEntity);

            if (propRelated != null)
            {
                EntityUnique <TForeignEntity, TRelatedEntity> relatedUnique = getRUniq(ForeignEntity);

                TRelatedEntity RelatedEntity = relatedUnique.Entity;

                if (!RelatedEntity.IsNull())
                {
                    UpdateUniqueConstraint(foreignKey, getFKey(RelatedEntity));

                    // when an unchanged entity reference to added entity it's state change from unchanged to modified,
                    // therefore when insert added entity to database, any related entity can be added or modified.
                    if (RelatedEntity.HasBusy() || !RelatedEntity.HasChanged())
                    {
                        throw new EntityRelationManagerException($"[{this}] UpdatedAllRelated Failed, {RelatedEntity} With {RelatedEntity.State} State Is Not Supported");
                    }

                    setFKey(RelatedEntity, foreignKey);

                    RelatedEntity.State |= EntityState.Busy;

                    RelatedEntity.OnPropertyChanged(propForeignKey.Name);
                    RelatedEntity.OnPropertyChanged(propForeignReference.Name);

                    RelatedEntity.State ^= EntityState.Busy;
                }
            }
            else
            {
                foreach (TRelatedEntity RelatedEntity in relatedEntitySet)
                {
                    TForeignEntity foreignEntity = getFRef(RelatedEntity);

                    if (foreignEntity == ForeignEntity)
                    {
                        UpdateUniqueConstraint(foreignKey, getFKey(RelatedEntity));

                        // when an unchanged entity reference to added entity it's state change from unchanged to modified,
                        // therefore when insert added entity to database, any related entity can be added or modified.
                        if (RelatedEntity.HasBusy() || !RelatedEntity.HasChanged())
                        {
                            throw new EntityRelationManagerException($"[{this}] UpdatedAllRelated Failed, {RelatedEntity} With {RelatedEntity.State} State Is Not Supported");
                        }

                        setFKey(RelatedEntity, foreignKey);

                        RelatedEntity.State |= EntityState.Busy;

                        RelatedEntity.OnPropertyChanged(propForeignKey.Name);
                        RelatedEntity.OnPropertyChanged(propForeignReference.Name);

                        RelatedEntity.State ^= EntityState.Busy;

                        break;
                    }
                }
            }
        }