Beispiel #1
0
        public void BasicDynamicDataReaderTimerTest()
        {
            var     data   = new SqlDataAccess("server=.;database=WestwindWebStore_Client;integrated security=true;");
            dynamic reader = data.ExecuteDynamicDataReader("select * from wws_items");

            Assert.IsNotNull(reader, "Query Failure: " + data.ErrorMessage);


            StringBuilder sb = new StringBuilder();

            Stopwatch watch = new Stopwatch();

            watch.Start();


            while (reader.Read())
            {
                string  sku      = reader.Sku;
                string  descript = reader.Descript;
                decimal?price    = reader.Price;

                sb.AppendLine(sku + " " + descript + " " + price.Value.ToString("n2"));
            }

            watch.Stop();

            reader.Close();

            Console.WriteLine(watch.ElapsedMilliseconds.ToString());
            Console.WriteLine(sb.ToString());
        }
        public void ExecuteDynamicDataReaderTest()
        {
            using (var data = new SqlDataAccess(STR_ConnectionString))
            {
                var swatch = Stopwatch.StartNew();
                var reader =
                    data.ExecuteDynamicDataReader(
                        "select * from ApplicationLog where entered > @0 and entered < @1 order by Entered",
                        DateTime.Now.AddYears(-115), DateTime.Now.AddYears(-1));
                Assert.IsNotNull(reader, data.ErrorMessage);

                while (reader.Read())
                {
                    Console.WriteLine(reader.Entered);
                }
                swatch.Stop();
                Console.WriteLine(swatch.ElapsedMilliseconds + "ms");
            }
        }