Beispiel #1
0
        public ActionResult InsertEntries(int numberOfInserts, OrmTypes ormType)
        {
            var rnd = new Random();
            var sw = new Stopwatch();
            sw.Start();

            for (int i = 0; i < numberOfInserts; i++)
            {
                var chars  = Enumerable.Range(0, 100).Select(x => _alphabet[rnd.Next(0, _alphabet.Length)]);       //Generate some random characters to simulate actual data
                int number = rnd.Next(100,1000);

                IDataAccess currentRepo = DataAccessFactory.GetDataLib(ormType, Properties.Settings.Default.ProductContext);

                currentRepo.Insert(new Product()
                {
                    ProductDescription = new string(chars.ToArray<char>()),
                    ProductName = (new string(chars.ToArray<char>())).Substring(0,10),
                    Quantity = number,
                    IsOnSale = false
                });
            }

            sw.Stop();

            return Json(new { time = sw.ElapsedMilliseconds.ToString() }, JsonRequestBehavior.AllowGet);
        }
Beispiel #2
0
 /// <summary>
 /// Static Factory Method, ORM type selection delegated to this class
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static IDataAccess GetDataLib(OrmTypes type, string connString)
 {
     switch (type)
     {
             case OrmTypes.BareMetal:
                 return new AdoDb(connString);
             case OrmTypes.Dapper:
                 return new DapperDb(connString);
             case OrmTypes.EntityFramework:
                 return new EfDb(connString);
         default:
             throw new Exception("ORM Type not specified!");
     }
 }
Beispiel #3
0
        public ActionResult ReadEntries(int numberOfReads, OrmTypes ormType)
        {
            var sw = new Stopwatch();
            sw.Start();

            IDataAccess currentRepo = DataAccessFactory.GetDataLib(ormType, Properties.Settings.Default.ProductContext);
            var results = new List<Product>();

            for (int i = 1; i <= numberOfReads; i++)
            {
                var rnd = new Random();     //This randomizes the ID of the searched Product

                results.Add(currentRepo.Read(rnd.Next(1, numberOfReads)));
            }

            sw.Stop();

            return Json(new { time = sw.ElapsedMilliseconds.ToString(), count = results.Count },JsonRequestBehavior.AllowGet);
        }