public static async Task <SquidexEntities <TEntity, TData> > GetAllAsync <TEntity, TData>(this SquidexClient <TEntity, TData> client, int batchSize = 200)
            where TEntity : SquidexEntityBase <TData>
            where TData : class, new()
        {
            var skip     = 0;
            var entities = new SquidexEntities <TEntity, TData>();

            do
            {
                var getResult = await client.GetAsync(skip : skip, top : batchSize);

                entities.Total = getResult.Total;
                entities.Items.AddRange(getResult.Items);

                skip += entities.Items.Count;
            }while (skip < entities.Total);

            return(entities);
        }
Esempio n. 2
0
        public static async Task <SquidexEntities <TEntity, TData> > GetAllAsync <TEntity, TData>(this SquidexClient <TEntity, TData> client, int batchSize = 200)
            where TEntity : SquidexEntityBase <TData> where TData : class, new()
        {
            var query = new ContentQuery {
                Top = batchSize
            };

            var entities = new SquidexEntities <TEntity, TData>();

            do
            {
                var getResult = await client.GetAsync(query);

                entities.Total = getResult.Total;
                entities.Items.AddRange(getResult.Items);

                query.Skip = entities.Items.Count;
            }while (query.Skip < entities.Total);

            return(entities);
        }