public ParaEntityList <TEntity> GetList <TEntity>(ParaEntityQuery query) where TEntity : ParaEntity, new() { if (!(query.QueryTargetType == typeof(TEntity))) { throw new ArgumentException("Invalid query type for the requested entity result type", "query"); } if (query.IncludeAllCustomFields) { var objschem = Create <TEntity>(); query.IncludeCustomField(objschem.CustomFields); } return(ApiUtils.ApiGetEntityList <TEntity>(Credentials, query)); }
/// <summary> /// Fills a main module's list object. /// </summary> internal static ParaEntityList <T> ApiGetEntityList <T>(ParaCredentials pc, ParaEntityQuery query) where T : ParaEntity, new() { var entityList = new ParaEntityList <T>(); // Checking if the system needs to recursively call all of the data returned. if (query.RetrieveAllRecords) { entityList = RetrieveAllEntities <T>(pc, query); } else { var ar = ApiCallFactory.ObjectGetList <T>(pc, query.BuildQueryArguments()); if (ar.HasException == false) { entityList = ParaEntityParser.FillList <T>(ar.XmlReceived); } entityList.ApiCallResponse = ar; } return(entityList); }
private static ParaEntityList <T> RetrieveAllEntities <T>(ParaCredentials pc, ParaEntityQuery query) where T : ParaEntity, new() { ApiCallResponse ar; var entityList = new ParaEntityList <T>(); ar = ApiCallFactory.ObjectGetList <T>(pc, query.BuildQueryArguments()); if (ar.HasException == false) { entityList = ParaEntityParser.FillList <T>(ar.XmlReceived); } entityList.ApiCallResponse = ar; var continueCalling = true; while (continueCalling) { if (entityList.TotalItems > entityList.Data.Count) { // We still need to pull data // Getting next page's data query.PageNumber = query.PageNumber + 1; ar = ApiCallFactory.ObjectGetList <T>(pc, query.BuildQueryArguments()); if (ar.HasException == false) { var objectlist = ParaEntityParser.FillList <T>(ar.XmlReceived); entityList.Data.AddRange(objectlist.Data); entityList.ResultsReturned = entityList.Data.Count; entityList.PageNumber = query.PageNumber; } else { // There is an error processing request entityList.ApiCallResponse = ar; continueCalling = false; } } else { // That is it, pulled all the items. continueCalling = false; entityList.ApiCallResponse = ar; } } return(entityList); }