public decimal GetInsertTimeStatisticsAddRangeWithDbContextRecycle(bool useDbSetToSave)
        {
            var amazonAddressInsertLabMapper = new AmazonAddressInsertLabMapper();
            var fiveThousandInsertTimes      = new List <decimal>();

            amazonAddressInsertLabMapper.CleanAddressData();

            for (int i = 0; i < 3; i++)
            {
                var fiveThousandAddress = MakeFiveThousandAddress();

                using (var amazonCodeFirstContext = new AmazonCodeFirstDbContext())
                {
                    var fiveThousandInsertTime = useDbSetToSave
                                                ? amazonAddressInsertLabMapper.InsertAddressWithDbSetWithAddRange(amazonCodeFirstContext, fiveThousandAddress)
                                                : amazonAddressInsertLabMapper.InsertAddressWithDbContextWithAddRange(amazonCodeFirstContext, fiveThousandAddress);

                    fiveThousandInsertTimes.Add(fiveThousandInsertTime);
                }
            }

            var fiveThousandInsertTimeAverage = Enumerable.Average(fiveThousandInsertTimes);
            var insertTime = decimal.Divide(fiveThousandInsertTimeAverage, 5_000);

            return(insertTime);
        }
        public decimal GetUpdateTimeStatisticsAddRangeWithDbContextRecycle(bool useDbSetToSave)
        {
            var fifteenThousandAddressWithoutId = MakeFifteenThousandAddress(generateIncrementalId: false);

            var amazonAddressInsertLabMapper = new AmazonAddressInsertLabMapper();
            var amazonAddressUpdateLabMapper = new AmazonAddressUpdateLabMapper();
            var fiveThousandUpdatesTimes     = new List <decimal>();

            using (var amazonCodeFirstContext = new AmazonCodeFirstDbContext())
            {
                amazonAddressInsertLabMapper.CleanAddressData(amazonCodeFirstContext);
            }

            amazonAddressInsertLabMapper.InsertAddressWithDbSetWithAddRange(fifteenThousandAddressWithoutId);

            for (int i = 0; i < 3; i++)
            {
                var fiveThousandAddress = MakeFiveThousandAddress((i * 5000) + 4);

                using (var amazonCodeFirstContext = new AmazonCodeFirstDbContext())
                {
                    var fiveThousandUpdateTime = useDbSetToSave
                                                 ? amazonAddressUpdateLabMapper.UpdateAddressWithDbSetWithAddRange(amazonCodeFirstContext, fiveThousandAddress)
                                                 : amazonAddressUpdateLabMapper.UpdateAddressWithDbContextWithAddRange(amazonCodeFirstContext, fiveThousandAddress);

                    fiveThousandUpdatesTimes.Add(fiveThousandUpdateTime);
                }
            }

            var fiveThousandUpdateTimeAverage = Enumerable.Average(fiveThousandUpdatesTimes);
            var insertTime = decimal.Divide(fiveThousandUpdateTimeAverage, 5_000);

            return(insertTime);
        }
        public InsertTimeStatistics GetInsertTimeStatisticsWithExecuteSqlInterpolatedWithDbContextRecycle()
        {
            var insertTimeStatistics   = new InsertTimeStatistics();
            var rowsInserted           = 0;
            var fifteenThousandAddress = MakeFifteenThousandAddress();
            var rowCutOffToEmptyTable  = Faker.RandomNumber.Next(5, 100);
            var rowCutOffToTableWithFiveThousandRows = Faker.RandomNumber.Next(6_000, 9_000);
            var rowCutOffToTableWithTenThousandRows  = Faker.RandomNumber.Next(11_000, 14_000);
            var tenInsertTimes = new List <long>();
            var amazonAddressInsertLabMapper = new AmazonAddressInsertLabMapper();

            amazonAddressInsertLabMapper.CleanAddressData();

            foreach (var address in fifteenThousandAddress)
            {
                var insertTime = amazonAddressInsertLabMapper.InsertAddressWithExecuteSqlInterpolated(address);

                rowsInserted++;

                if (IsRowToBeComputed(rowsInserted, rowCutOffToEmptyTable))
                {
                    tenInsertTimes.Add(insertTime);

                    if (tenInsertTimes.Count == _tenRegisters)
                    {
                        var insertTimesAverage = Enumerable.Average(tenInsertTimes);
                        insertTimeStatistics.MillisecondsAverageBasedOnTenInsertsWithEmptyTable = insertTimesAverage;
                        tenInsertTimes.Clear();
                    }
                }

                if (IsRowToBeComputed(rowsInserted, rowCutOffToTableWithFiveThousandRows))
                {
                    tenInsertTimes.Add(insertTime);

                    if (tenInsertTimes.Count == _tenRegisters)
                    {
                        var insertTimesAverage = Enumerable.Average(tenInsertTimes);
                        insertTimeStatistics.MillisecondsAverageBasedOnTenInsertsWithTableWithFiveThousandsRows = insertTimesAverage;
                        tenInsertTimes.Clear();
                    }
                }

                if (IsRowToBeComputed(rowsInserted, rowCutOffToTableWithTenThousandRows))
                {
                    tenInsertTimes.Add(insertTime);

                    if (tenInsertTimes.Count == _tenRegisters)
                    {
                        var insertTimesAverage = Enumerable.Average(tenInsertTimes);
                        insertTimeStatistics.MillisecondsAverageBasedOnTenInsertsWithTableWithTenThousandsRows = insertTimesAverage;
                        tenInsertTimes.Clear();
                    }
                }
            }

            return(insertTimeStatistics);
        }
        public decimal GetInsertTimeWithBulkOperation()
        {
            var amazonAddressInsertLabMapper = new AmazonAddressInsertLabMapper();
            var fifteenThousandAddress       = MakeFifteenThousandAddressIlist();

            amazonAddressInsertLabMapper.CleanAddressData();

            var insertTimeAllRecords = amazonAddressInsertLabMapper.InsertAddressWithBulkOperation(fifteenThousandAddress);

            var insertTime = decimal.Divide(insertTimeAllRecords, fifteenThousandAddress.Count());

            return(insertTime);
        }
        public decimal GetInsertTimeStatisticsAddRange(bool useDbSetToSave)
        {
            var fifteenThousandAddress       = MakeFifteenThousandAddress();
            var amazonAddressInsertLabMapper = new AmazonAddressInsertLabMapper();

            amazonAddressInsertLabMapper.CleanAddressData();

            var insertTimeAllRecords = useDbSetToSave
                                       ? amazonAddressInsertLabMapper.InsertAddressWithDbSetWithAddRange(fifteenThousandAddress)
                                       : amazonAddressInsertLabMapper.InsertAddressWithDbContextWithAddRange(fifteenThousandAddress);

            var insertTime = decimal.Divide(insertTimeAllRecords, fifteenThousandAddress.Count());

            return(insertTime);
        }
        public decimal GetUpdateTimeWithBulkOperation()
        {
            var fifteenThousandAddressWithoutId = MakeFifteenThousandAddress(generateIncrementalId: false);
            var fifteenThousandAddressIlist     = MakeFifteenThousandAddressIlist();

            var amazonAddressInsertLabMapper = new AmazonAddressInsertLabMapper();
            var amazonAddressUpdateLabMapper = new AmazonAddressUpdateLabMapper();

            amazonAddressInsertLabMapper.CleanAddressData();
            amazonAddressInsertLabMapper.InsertAddressWithDbSetWithAddRange(fifteenThousandAddressWithoutId);

            var updateTimeAllRecords = amazonAddressUpdateLabMapper.UpdateAddressWithBulkOperation(fifteenThousandAddressIlist);

            var updateTime = decimal.Divide(updateTimeAllRecords, fifteenThousandAddressIlist.Count());

            return(updateTime);
        }
        public decimal GetUpdateTimeStatisticsAddRange(bool useDbSetToSave)
        {
            var fifteenThousandAddressWithoutId = MakeFifteenThousandAddress(generateIncrementalId: false);
            var fifteenThousandAddress          = MakeFifteenThousandAddress(generateIncrementalId: true);

            var amazonAddressInsertLabMapper = new AmazonAddressInsertLabMapper();
            var amazonAddressUpdateLabMapper = new AmazonAddressUpdateLabMapper();

            using (var amazonCodeFirstContext = new AmazonCodeFirstDbContext())
            {
                amazonAddressInsertLabMapper.CleanAddressData(amazonCodeFirstContext);
                amazonAddressInsertLabMapper.InsertAddressWithDbSetWithAddRange(fifteenThousandAddressWithoutId);

                var updateTimeAllRecords = useDbSetToSave
                                           ? amazonAddressUpdateLabMapper.UpdateAddressWithDbSetWithAddRange(fifteenThousandAddress)
                                           : amazonAddressUpdateLabMapper.UpdateAddressWithDbContextWithAddRange(fifteenThousandAddress);

                var updateTime = decimal.Divide(updateTimeAllRecords, fifteenThousandAddress.Count());

                return(updateTime);
            }
        }
        public UpdateTimeStatistics GetUpdateTimeStatisticsWithDbContextRecycle(bool useDbSetToSave)
        {
            var updateTimeStatistics                 = new UpdateTimeStatistics();
            var rowsUpdated                          = 0;
            var fifteenThousandAddressWithoutId      = MakeFifteenThousandAddress(generateIncrementalId: false);
            var fifteenThousandAddress               = MakeFifteenThousandAddress(generateIncrementalId: true);
            var rowCutOffToEmptyTable                = Faker.RandomNumber.Next(5, 100);
            var rowCutOffToTableWithFiveThousandRows = Faker.RandomNumber.Next(6_000, 9_000);
            var rowCutOffToTableWithTenThousandRows  = Faker.RandomNumber.Next(11_000, 14_000);

            var tenUpdateTimes = new List <long>();
            var amazonAddressInsertLabMapper = new AmazonAddressInsertLabMapper();
            var amazonAddressUpdateLabMapper = new AmazonAddressUpdateLabMapper();

            using (var amazonCodeFirstContext = new AmazonCodeFirstDbContext())
            {
                amazonAddressInsertLabMapper.CleanAddressData(amazonCodeFirstContext);
                amazonAddressInsertLabMapper.InsertAddressWithDbSetWithAddRange(fifteenThousandAddressWithoutId);

                foreach (var address in fifteenThousandAddress)
                {
                    address.Street = "Updated Street";

                    var updateTime = useDbSetToSave
                                        ? amazonAddressUpdateLabMapper.UpdateAddressWithDbSet(address)
                                        : amazonAddressUpdateLabMapper.UpdateAddressWithDbContext(address);

                    rowsUpdated++;

                    if (IsRowToBeComputed(rowsUpdated, rowCutOffToEmptyTable))
                    {
                        tenUpdateTimes.Add(updateTime);

                        if (tenUpdateTimes.Count == _tenRegisters)
                        {
                            var updateTimesAverage = Enumerable.Average(tenUpdateTimes);
                            updateTimeStatistics.MillisecondsAverageBasedOnTenUpdatesWithEmptyTable = updateTimesAverage;
                            tenUpdateTimes.Clear();
                        }
                    }

                    if (IsRowToBeComputed(rowsUpdated, rowCutOffToTableWithFiveThousandRows))
                    {
                        tenUpdateTimes.Add(updateTime);

                        if (tenUpdateTimes.Count == _tenRegisters)
                        {
                            var updateTimesAverage = Enumerable.Average(tenUpdateTimes);
                            updateTimeStatistics.MillisecondsAverageBasedOnTenUpdatesWithTableWithFiveThousandsRows = updateTimesAverage;
                            tenUpdateTimes.Clear();
                        }
                    }

                    if (IsRowToBeComputed(rowsUpdated, rowCutOffToTableWithTenThousandRows))
                    {
                        tenUpdateTimes.Add(updateTime);

                        if (tenUpdateTimes.Count == _tenRegisters)
                        {
                            var updateTimesAverage = Enumerable.Average(tenUpdateTimes);
                            updateTimeStatistics.MillisecondsAverageBasedOnTenUpdatesWithTableWithTenThousandsRows = updateTimesAverage;
                            tenUpdateTimes.Clear();
                        }
                    }
                }
            }

            return(updateTimeStatistics);
        }
        public DeleteTimeStatistics GetDeleteTimeStatisticsWithExecuteSqlInterpolatedWithDbContextRecycle()
        {
            var deleteTimeStatistics                 = new DeleteTimeStatistics();
            var rowsDeleted                          = 0;
            var fifteenThousandAddressWithoutId      = MakeFifteenThousandAddress(generateIncrementalId: false);
            var fifteenThousandAddress               = MakeFifteenThousandAddress(generateIncrementalId: true);
            var rowCutOffToEmptyTable                = Faker.RandomNumber.Next(5, 100);
            var rowCutOffToTableWithFiveThousandRows = Faker.RandomNumber.Next(6_000, 9_000);
            var rowCutOffToTableWithTenThousandRows  = Faker.RandomNumber.Next(11_000, 14_000);

            var tenDeleteTimes = new List <long>();
            var amazonAddressInsertLabMapper = new AmazonAddressInsertLabMapper();
            var amazonAddressDeleteLabMapper = new AmazonAddressDeleteLabMapper();

            amazonAddressInsertLabMapper.CleanAddressData();
            amazonAddressInsertLabMapper.InsertAddressWithDbSetWithAddRange(fifteenThousandAddressWithoutId);

            foreach (var address in fifteenThousandAddress)
            {
                var deleteTime = amazonAddressDeleteLabMapper.DeleteAddressWithExecuteSqlInterpolated(address);

                rowsDeleted++;

                if (IsRowToBeComputed(rowsDeleted, rowCutOffToEmptyTable))
                {
                    tenDeleteTimes.Add(deleteTime);

                    if (tenDeleteTimes.Count == _tenRegisters)
                    {
                        var deleteTimesAverage = Enumerable.Average(tenDeleteTimes);
                        deleteTimeStatistics.MillisecondsAverageBasedOnTenDeletesWithEmptyTable = deleteTimesAverage;
                        tenDeleteTimes.Clear();
                    }
                }

                if (IsRowToBeComputed(rowsDeleted, rowCutOffToTableWithFiveThousandRows))
                {
                    tenDeleteTimes.Add(deleteTime);

                    if (tenDeleteTimes.Count == _tenRegisters)
                    {
                        var deleteTimesAverage = Enumerable.Average(tenDeleteTimes);
                        deleteTimeStatistics.MillisecondsAverageBasedOnTenDeletesWithTableWithFiveThousandsRows = deleteTimesAverage;
                        tenDeleteTimes.Clear();
                    }
                }

                if (IsRowToBeComputed(rowsDeleted, rowCutOffToTableWithTenThousandRows))
                {
                    tenDeleteTimes.Add(deleteTime);

                    if (tenDeleteTimes.Count == _tenRegisters)
                    {
                        var deleteTimesAverage = Enumerable.Average(tenDeleteTimes);
                        deleteTimeStatistics.MillisecondsAverageBasedOnTenDeletesWithTableWithTenThousandsRows = deleteTimesAverage;
                        tenDeleteTimes.Clear();
                    }
                }
            }

            return(deleteTimeStatistics);
        }