private List <dynamic> readEntity(MetaFunctions CFunc, WSJProperty jProp, WSDynamicEntity _entity, bool multydimentional = false)
 {
     try
     {
         if (_entity != null)
         {
             WSTableSource src   = (WSTableSource)_entity.getSource(CFunc);
             WSTableParam  param = src.DBParams.FirstOrDefault(p => p.Match(jProp.Key));
             PropertyInfo  pInfo = src.ReturnType.GetProperties().FirstOrDefault(p => p.Name.Equals(param.WSColumnRef.NAME));
             dynamic       val   = pInfo.GetValue(_entity, null);
             Type          pType = pInfo.PropertyType.GetEntityType();
             if (pInfo.PropertyType.IsCollectionOf <WSDynamicEntity>())
             {
                 IEnumerable <WSDynamicEntity> entities = (IEnumerable <WSDynamicEntity>)val;
                 List <dynamic> subItems = new List <dynamic>();
                 foreach (WSDynamicEntity iEntity in entities)
                 {
                     subItems.AddRange(read(CFunc, jProp.Value, iEntity, multydimentional));
                 }
                 return(subItems);
             }
             else
             {
                 return(read(CFunc, jProp.Value, val, multydimentional));
             }
         }
     }
     catch (Exception e) { WSStatus status = WSStatus.NONE.clone(); CFunc.RegError(GetType(), e, ref status, $"readEntity():284"); }
     return(null);
 }
        public bool IsRelationTo(ClientFunctions CFunc, WSDynamicEntity _RelationTEntity, ref WSStatus _statusLines, IEnumerable <Type> _refTypes = null)
        {
            bool _IsRelationTo = false;

            try
            {
                if (_RelationTEntity != null)
                {
                    WSTableSource orgSrc = (WSTableSource)getSource(CFunc);
                    WSTableSource relSrc = (WSTableSource)_RelationTEntity.getSource(CFunc);
                    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;

                                    _IsRelationTo = pEntity.IsRelationTo(CFunc, _RelationTEntity, ref _statusLines, refTypes);

                                    if (_IsRelationTo)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            object          PValue    = null;
                            WSDynamicEntity RefEntity = TryReadPropertyValue(refParam.WSColumnRef.NAME, out PValue, null) ? (WSDynamicEntity)PValue : null;

                            _IsRelationTo = RefEntity != null && _RelationTEntity.Match(CFunc, RefEntity);
                        }
                    }
                }
            }
            catch (Exception e) { CFunc.RegError(GetType(), e, ref _statusLines, $"IsRelationTo():256"); }
            return(_IsRelationTo);
        }