///<include file='docs.xml' path='doc/members/member[@name="M:GenericRepositoryAndService.Repository.GenericRepository`1.SetNewParamFromContextList(System.Data.Entity.DbContext,GenericRepositoryAndService.Repository.GenericRepository{`0}.CustomParam)"]/*'/>
        private CustomParam SetNewParamFromContextList(DbContext newContext, CustomParam customParam)
        {
            var newvalue = Convert.ChangeType(
                Activator.CreateInstance(typeof(List <>).MakeGenericType(customParam.TypeofElement)),
                typeof(List <>).MakeGenericType(customParam.TypeofElement)
                );

            if (customParam.Value != null)
            {
                foreach (object item in customParam.Value as IList)
                {
                    object newitem;
                    if (item is BaseEntity entity)
                    {
                        newitem = newContext.Set(customParam.TypeofElement).Find(entity.Id);
                    }
                    else
                    {
                        object[] objs = GenericToolsTypeAnalysis.GetKeysValuesForType(item, customParam.TypeofElement);
                        newitem = GenericToolsCRUD.FindByKeysInNewContextForType(customParam.TypeofElement, newContext, objs);
                    }
                    ((IList)newvalue).Add(newitem);
                }
            }
            return(new CustomParam(
                       newvalue,
                       customParam.TypeofElement,
                       customParam.PropertyName,
                       customParam.Prop,
                       true
                       ));
        }
        ///<include file='docs.xml' path='doc/members/member[@name="M:GenericRepositoryAndService.Repository.GenericRepository`1.SetNewParamFromContextNotList(System.Data.Entity.DbContext,GenericRepositoryAndService.Repository.GenericRepository{`0}.CustomParam)"]/*'/>
        private CustomParam SetNewParamFromContextNotList(DbContext newContext, CustomParam customParam)
        {
            object newvalue = null;

            if (customParam.Value != null)
            {
                if (customParam.Value is BaseEntity entity)
                {
                    newvalue = newContext.Set(customParam.TypeofElement).Find(entity.Id);
                }
                else
                {
                    object[] objs = GenericToolsTypeAnalysis.GetKeysValuesForType(customParam.Value, customParam.TypeofElement);
                    newvalue = GenericToolsCRUD.FindByKeysInNewContextForType(customParam.TypeofElement, newContext, objs);
                }
            }
            return(new CustomParam(
                       newvalue,
                       customParam.TypeofElement,
                       customParam.PropertyName,
                       customParam.Prop,
                       false
                       ));
        }