Ejemplo n.º 1
0
        private static async Task PerformanceTest_ReadAllPaged <TEntity, TId>(ServiceProvider serviceProvider, IMapper mapper, int page, int pageSize)
            where TEntity : class, IEntity <TId>, new()
            where TId : IEquatable <TId>
        {
            var watch = new Stopwatch();

            watch.Start();

            var mongoContext = serviceProvider.GetService <Mongo.StoreContext>();

            var dbset = mongoContext.Set <TEntity, TId>();

            var pagedOptions = Paged.BuildPagedOptions <TEntity>(page, pageSize);
            var models       = await dbset.ToListAsync(pagedOptions);

            var amount = models.Count();
            var dtos   = models.Select(x => mapper.Map <EntityDTO>(x)).ToList();

            mongoContext.ClearContext();

            watch.Stop();
            var testName = "Read All Paged";

            PerformanceTestResult <TEntity>(testName, amount, watch);
        }