Exemplo n.º 1
0
        public void MemoryDataExcercises(int qtyRecords)
        {
            // Start from fresh:
            this.DropTransctionTable();
            this.CreateTransctionTable();

            // Load the empty table:
            var transactions = new MassiveList <Transaction>(_connectionString, _tableName, _tablePkName);

            transactions.Clear();

            var sw = new Stopwatch();

            sw.Start();

            // Insert a bunch of records:
            var data = this.getSkinnyTransactionSet(qtyRecords);

            transactions.AddRange(data);
            sw.Stop();
            this.LogOutput("Wrote", qtyRecords, sw.ElapsedMilliseconds);

            transactions = this.ReadTransactionTable();

            sw.Reset();
            sw.Start();

            // Find a record by arbitrary field (NOT the PK):
            var item = transactions.First(t => t.Identifier == "AA-9000");

            sw.Stop();
            this.LogOutput("Found single by field content", 1, sw.ElapsedMilliseconds);
            this.LogOutput("Found item: " + item.Identifier);


            sw.Reset();
            sw.Start();

            // Query against some criteria:
            var query = from t in transactions where (t.Amount > 100 && t.Amount < 150) select t;

            this.LogOutput("Read queried values from memory", query.Count(), sw.ElapsedMilliseconds);

            Console.WriteLine("Queried Values:");
            foreach (var trans in query)
            {
                this.LogOutput("Id: " + trans.TransactionId + " Comment: " + trans.Comment + " Amount: " + trans.Amount);
            }
            sw.Stop();
            this.LogOutput("Wrote queried values out to console", query.Count(), sw.ElapsedMilliseconds);
        }
Exemplo n.º 2
0
        public void MemoryDataExcercises(int qtyRecords)
        {
            // Start from fresh:
            this.DropTransctionTable();
            this.CreateTransctionTable();

            // Load the empty table:
            var transactions = new MassiveList<Transaction>(_connectionString, _tableName, _tablePkName);
            transactions.Clear();

            var sw = new Stopwatch();
            sw.Start();

            // Insert a bunch of records:
            var data = this.getSkinnyTransactionSet(qtyRecords);
            transactions.AddRange(data);
            sw.Stop();
            this.LogOutput("Wrote", qtyRecords, sw.ElapsedMilliseconds);

            transactions = this.ReadTransactionTable();

            sw.Reset();
            sw.Start();

            // Find a record by arbitrary field (NOT the PK):
            var item = transactions.First(t => t.Identifier == "AA-9000");
            sw.Stop();
            this.LogOutput("Found single by field content", 1, sw.ElapsedMilliseconds);
            this.LogOutput("Found item: " + item.Identifier);

            sw.Reset();
            sw.Start();

            // Query against some criteria:
            var query = from t in transactions where (t.Amount > 100 && t.Amount < 150) select t;
            this.LogOutput("Read queried values from memory", query.Count(), sw.ElapsedMilliseconds);

            Console.WriteLine("Queried Values:");
            foreach(var trans in query)
            {
                this.LogOutput("Id: " + trans.TransactionId + " Comment: " + trans.Comment + " Amount: " + trans.Amount);
            }
            sw.Stop();
            this.LogOutput("Wrote queried values out to console", query.Count(), sw.ElapsedMilliseconds);
        }
Exemplo n.º 3
0
        public void ClearTransactionTable()
        {
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("CLEAR TRANSACTIONS TABLE");

            var sw = new Stopwatch();
            sw.Start();
            var transactions = new MassiveList<Transaction>(_connectionString, _tableName, _tablePkName);
            int count = transactions.Count;
            sw.Stop();
            this.LogOutput("Read", count, sw.ElapsedMilliseconds);

            sw.Reset();
            sw.Start();
            transactions.Clear();
            sw.Stop();
            this.LogOutput("Cleared", count, sw.ElapsedMilliseconds);
        }
Exemplo n.º 4
0
        public void ClearTransactionTable()
        {
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("CLEAR TRANSACTIONS TABLE");

            var sw = new Stopwatch();

            sw.Start();
            var transactions = new MassiveList <Transaction>(_connectionString, _tableName, _tablePkName);
            int count        = transactions.Count;

            sw.Stop();
            this.LogOutput("Read", count, sw.ElapsedMilliseconds);

            sw.Reset();
            sw.Start();
            transactions.Clear();
            sw.Stop();
            this.LogOutput("Cleared", count, sw.ElapsedMilliseconds);
        }