private static async Task PerformanceTest_ReadFiltered <TEntity, TId>(ServiceProvider serviceProvider, IMapper mapper) 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>(); object id = null; if (typeof(TId) == typeof(Guid)) { id = Ids.GetGuid(); } else { id = Ids.GetObjectId(); } var models = await dbset.Where(x => x.ProjectId.Equals(id)).ToListAsync(); var amount = models.Count(); var dtos = models.Select(x => mapper.Map <EntityDTO>(x)).ToList(); mongoContext.ClearContext(); watch.Stop(); var testName = "Read Filtered"; PerformanceTestResult <TEntity>(testName, amount, watch); }
public EntityGuid() { Id = Guid.NewGuid(); StoreName = "some name 01"; TotalValue = 11.0M; ProjectId = Ids.GetGuid(); CreatedAt = RandomDay(); }