private bool Match(ClientFunctions CFunc, WSDynamicEntity refEntity)
        {
            try
            {
                if (refEntity == null)
                {
                    return(false);
                }
                else if (refEntity.GetType() != GetType())
                {
                    return(false);
                }
                else
                {
                    Type          orgType = GetType();
                    WSTableSource orgSrc  = (WSTableSource)getSource(CFunc);
                    IEnumerable <WSTableParam> orgParams = orgSrc.DBParams.Where(p => p.DataType.IsSimple());

                    Type          refType = refEntity.GetType();
                    WSTableSource refSrc  = ((WSTableSource)CFunc.GetSourceByType(refType));
                    IEnumerable <WSTableParam> refParams = refSrc.DBParams.Where(p => p.DataType.IsSimple());

                    IEnumerable <WSTableParam> orgExceptParams = orgParams.Where(p1 => !refParams.Any(p2 => p2.Match(p1)));
                    IEnumerable <WSTableParam> refExceptParams = refParams.Where(p1 => !orgParams.Any(p2 => p2.Match(p1)));

                    if (orgExceptParams.Any() || refExceptParams.Any())
                    {
                        return(false);
                    }
                    else
                    {
                        foreach (WSTableParam param in orgParams)
                        {
                            object orgInfo = orgType.GetProperties().FirstOrDefault(p => p.Name.Equals(param.WSColumnRef.NAME)).GetValue(this, null);
                            object refInfo = refType.GetProperties().FirstOrDefault(p => p.Name.Equals(param.WSColumnRef.NAME)).GetValue(refEntity, null);
                            if (!(orgInfo == null && refInfo == null) && !orgInfo.ToString().Equals(refInfo.ToString()))
                            {
                                return(false);
                            }
                        }
                        return(true);
                    }
                }
            }
            catch (Exception e) { WSStatus status = WSStatus.NONE.clone(); CFunc.RegError(GetType(), e, ref status, $"Match():321"); }
            return(false);
        }
        public WSDynamicEntity getRelatedParent <A>(ClientFunctions CFunc, ref WSStatus _statusLines, IEnumerable <Type> _refTypes = null)
        {
            WSDynamicEntity relEntity = null;

            try
            {
                WSTableSource orgSrc = (WSTableSource)getSource(CFunc);
                WSTableSource relSrc = (WSTableSource)CFunc.GetSourceByType(typeof(A));
                if (relSrc != null)
                {
                    WSTableParam refParam = orgSrc.DBParams.FirstOrDefault(x => x.DataType == relSrc.ReturnType);
                    if (refParam == null)
                    {
                        IEnumerable <Type>         refTypes = _refTypes == null ? new List <Type>() : _refTypes.Select(x => x);
                        IEnumerable <WSTableParam> eParams  = orgSrc.DBParams.Any() ? orgSrc.DBParams.Where(x => x.DataType.IsValidDynamicEntity() && !x.DataType.IsCollection() && !refTypes.Any(t => t == x.DataType)) : null;
                        if (eParams != null && eParams.Any())
                        {
                            foreach (WSTableParam eParam in eParams)
                            {
                                object          pValue  = null;
                                WSDynamicEntity pEntity = TryReadPropertyValue(eParam.WSColumnRef.NAME, out pValue, null) ? (WSDynamicEntity)pValue : null;

                                relEntity = pEntity.getRelatedParent <A>(CFunc, ref _statusLines, refTypes);

                                if (relEntity != null)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        object PValue = null;
                        relEntity = TryReadPropertyValue(refParam.WSColumnRef.NAME, out PValue, null) ? (WSDynamicEntity)PValue : null;
                    }
                }
            }
            catch (Exception e) { CFunc.RegError(GetType(), e, ref _statusLines, $"getRelatedParent():211"); }
            return(relEntity);
        }