public void Biggylist_Updates_Range_Of_Items_In_Sqlite_Store()
        {
            var PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore);
            int initialCount         = PropertyDocumentList.Count;

            var myBatch  = new List <PropertyDocument>();
            int qtyToAdd = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                myBatch.Add(new PropertyDocument {
                    Name = "John's Luxury Townhomes" + i, Address = i + " PropertyDocument Parkway, Portland, OR 97204"
                });
            }
            PropertyDocumentList.Add(myBatch);

            // Just to be sure, reload from backing store and check what was added:
            PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore);
            int addedCount = PropertyDocumentList.Count;

            // Update each item:
            for (int i = 0; i < qtyToAdd; i++)
            {
                PropertyDocumentList.ElementAt(i).Name = "John's Low-Rent Brick Homes " + i;
            }
            PropertyDocumentList.Update(PropertyDocumentList.ToList());

            // Reload, and check updated names:
            PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore);
            var updatedItems = PropertyDocumentList.Where(p => p.Name.Contains("Low-Rent Brick"));

            Assert.IsTrue(updatedItems.Count() == qtyToAdd);
        }
Exemple #2
0
        public void Biggylist_Updates_Range_Of_Items_In_Json_Store()
        {
            var propertyList = new BiggyList <Property>(_propertyStore);
            int initialCount = propertyList.Count;

            var myBatch  = new List <Property>();
            int qtyToAdd = 10;

            // This test uses an initial index value of 1 so taht there is a non-zero ID for the first item:
            for (int i = 1; i <= qtyToAdd; i++)
            {
                myBatch.Add(new Property {
                    Id = i, Name = "John's Luxury Townhomes" + i, Address = i + " Property Parkway, Portland, OR 97204"
                });
            }
            propertyList.Add(myBatch);

            // Just to be sure, reload from backing store and check what was added:
            propertyList = new BiggyList <Property>(_propertyStore);
            int addedCount = propertyList.Count;

            // Update each item:
            for (int i = 0; i < qtyToAdd; i++)
            {
                propertyList.ElementAt(i).Name = "John's Low-Rent Brick Homes " + i;
            }
            propertyList.Update(propertyList.ToList());

            // Reload, and check updated names:
            propertyList = new BiggyList <Property>(_propertyStore);
            var updatedItems = propertyList.Where(p => p.Name.Contains("Low-Rent Brick"));

            Assert.IsTrue(updatedItems.Count() == qtyToAdd);
        }
Exemple #3
0
        public void Biggylist_Removes_Range_Of_Items_From_Json_Store()
        {
            var propertyList = new BiggyList <Property>(_propertyStore);
            int initialCount = propertyList.Count;

            var myBatch  = new List <Property>();
            int qtyToAdd = 10;

            // This test uses an initial index value of 1 so taht there is a non-zero ID for the first item:
            for (int i = 1; i <= qtyToAdd; i++)
            {
                myBatch.Add(new Property {
                    Id = i, Name = "Boardwalk " + i, Address = i + " Property Parkway, Portland, OR 97204"
                });
            }
            propertyList.Add(myBatch);

            // Re-load from back-end:
            propertyList = new BiggyList <Property>(_propertyStore);
            int qtyAdded = propertyList.Count;

            // Select 5 for deletion:
            int qtyToDelete = 5;
            var deleteThese = propertyList.Where(c => c.Id <= qtyToDelete);

            propertyList.Remove(deleteThese);

            // Delete:
            propertyList = new BiggyList <Property>(_propertyStore);
            int remaining = propertyList.Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
        }
Exemple #4
0
        public void Biggylist_Removes_Range_Of_Items_From_SQLite_Store()
        {
            var propertyList = new BiggyList <Property>(_propertyStore);
            int initialCount = propertyList.Count;

            var myBatch  = new List <Property>();
            int qtyToAdd = 10;

            for (int i = 0; i < qtyToAdd; i++)
            {
                myBatch.Add(new Property {
                    Name = "Boardwalk " + i, Address = i + " Property Parkway, Portland, OR 97204"
                });
            }
            propertyList.Add(myBatch);

            // Re-load from back-end:
            propertyList = new BiggyList <Property>(_propertyStore);
            int qtyAdded = propertyList.Count;

            // Select 5 for deletion:
            int qtyToDelete = 5;
            var deleteThese = propertyList.Where(c => c.Id <= qtyToDelete);

            propertyList.Remove(deleteThese);

            // Delete:
            propertyList = new BiggyList <Property>(_propertyStore);
            int remaining = propertyList.Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
        }
Exemple #5
0
        public static void Run()
        {
            Console.WriteLine("Loading from File Store...");
            var clients = new BiggyList <Client>(new JsonStore <Client>("clients"));

            clients.Clear();
            var sw = new Stopwatch();

            // Write a modest-sized batch to a file:
            int SMALL_BATCH_QTY = 1000;

            Console.WriteLine("Write {0} documents", SMALL_BATCH_QTY);
            var addRange = new List <Client>();

            for (int i = 0; i < SMALL_BATCH_QTY; i++)
            {
                addRange.Add(new Client()
                {
                    ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**"
                });
            }

            sw.Start();
            clients.Add(addRange);
            sw.Stop();
            Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds);


            int LARGE_BATCH_QTY = 100000;

            Console.WriteLine("Write {0} documents", LARGE_BATCH_QTY);
            sw.Reset();
            clients.Clear();

            // Write a Bigger-sized batch to a file:

            // Reset the temp List;
            addRange = new List <Client>();
            for (int i = 0; i < LARGE_BATCH_QTY; i++)
            {
                addRange.Add(new Client()
                {
                    ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**"
                });
            }

            sw.Start();
            clients.Add(addRange);
            sw.Stop();
            Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds);

            sw.Reset();
            sw.Start();
            Console.WriteLine("Querying Middle 400 Documents");
            var found = clients.Where(x => x.ClientId > 100 && x.ClientId < 500);

            sw.Stop();
            Console.WriteLine("Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds);
        }
Exemple #6
0
        public static void Run()
        {
            Console.WriteLine("Loading from File Store...");
            var monkies = new BiggyList <Monkey>();

            monkies.Clear();
            var sw = new Stopwatch();

            Console.WriteLine("Loading 10,000 documents");

            sw.Start();
            var addRange = new List <Monkey>();

            for (int i = 0; i < 10000; i++)
            {
                monkies.Add(new Monkey {
                    ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back"
                });
            }
            sw.Stop();
            Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count(), sw.ElapsedMilliseconds);


            Console.WriteLine("Loading 100,000 documents");
            sw.Reset();
            monkies.Clear();
            sw.Start();
            for (int i = 0; i < 100000; i++)
            {
                monkies.Add(new Monkey {
                    ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back"
                });
            }
            sw.Stop();
            Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count, sw.ElapsedMilliseconds);


            //use a DB that has an int PK
            sw.Reset();
            sw.Start();
            Console.WriteLine("Loading {0}...", monkies.Count);
            monkies.Reload();
            sw.Stop();
            Console.WriteLine("Loaded {0} documents from Postgres in {1}ms", monkies.Count, sw.ElapsedMilliseconds);

            sw.Reset();
            sw.Start();
            Console.WriteLine("Querying Middle 100 Documents");
            var found = monkies.Where(x => x.ID > 100 && x.ID < 500);

            sw.Stop();
            Console.WriteLine("Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds);
        }
Exemple #7
0
        public static void Run()
        {
            Console.WriteLine("Loading from File Store...");
              var clients = new BiggyList<Client>(new JsonStore<Client>("clients"));
              clients.Clear();
              var sw = new Stopwatch();

              // Write a modest-sized batch to a file:
              int SMALL_BATCH_QTY = 1000;

              Console.WriteLine("Write {0} documents", SMALL_BATCH_QTY);
              var addRange = new List<Client>();
              for (int i = 0; i < SMALL_BATCH_QTY; i++) {
            addRange.Add(new Client() { ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**" });
              }

              sw.Start();
              clients.Add(addRange);
              sw.Stop();
              Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds);

              int LARGE_BATCH_QTY = 100000;
              Console.WriteLine("Write {0} documents", LARGE_BATCH_QTY);
              sw.Reset();
              clients.Clear();

              // Write a Bigger-sized batch to a file:

              // Reset the temp List;
              addRange = new List<Client>();
              for (int i = 0; i < LARGE_BATCH_QTY; i++) {
            addRange.Add(new Client() { ClientId = i, LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**" });
              }

              sw.Start();
              clients.Add(addRange);
              sw.Stop();
              Console.WriteLine("Just inserted {0} as documents in {1} ms", clients.Count(), sw.ElapsedMilliseconds);

              sw.Reset();
              sw.Start();
              Console.WriteLine("Querying Middle 400 Documents");
              var found = clients.Where(x => x.ClientId > 100 && x.ClientId < 500);
              sw.Stop();
              Console.WriteLine("Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds);
        }
    public void Biggylist_Adds_Range_Of_Items_To_Sqlite_Store() {
      var PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore);
      int initialCount = PropertyDocumentList.Count;

      var myBatch = new List<PropertyDocument>();
      int qtyToAdd = 10;
      for (int i = 1; i <= qtyToAdd; i++) {
        var newPropertyDocument = new PropertyDocument { Name = "New Apartment " + i, Address = "Some Street in a Lonely Town" };
        myBatch.Add(newPropertyDocument);
      }
      PropertyDocumentList.Add(myBatch);

      // Reload from the store:
      PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore);

      var addedItems = PropertyDocumentList.Where(p => p.Id > 0);
      Assert.IsTrue(initialCount == 0 && addedItems.Count() > 0);
    }
Exemple #9
0
        public static void Run()
        {
            Console.WriteLine("Loading from File Store...");
              var monkies = new BiggyList<Monkey>();
              monkies.Clear();
              var sw = new Stopwatch();

              Console.WriteLine("Loading 10,000 documents");

              sw.Start();
              var addRange = new List<Monkey>();
              for (int i = 0; i < 10000; i++) {
            monkies.Add(new Monkey {ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" });
              }
              sw.Stop();
              Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count(), sw.ElapsedMilliseconds);

              Console.WriteLine("Loading 100,000 documents");
              sw.Reset();
              monkies.Clear();
              sw.Start();
              for (int i = 0; i < 100000; i++) {
            monkies.Add(new Monkey { ID = i, Name = "MONKEY " + i, Birthday = DateTime.Today, Description = "The Monkey on my back" });
              }
              sw.Stop();
              Console.WriteLine("Just inserted {0} as documents in {1} ms", monkies.Count, sw.ElapsedMilliseconds);

              //use a DB that has an int PK
              sw.Reset();
              sw.Start();
              Console.WriteLine("Loading {0}...", monkies.Count);
              monkies.Reload();
              sw.Stop();
              Console.WriteLine("Loaded {0} documents from Postgres in {1}ms", monkies.Count, sw.ElapsedMilliseconds);

              sw.Reset();
              sw.Start();
              Console.WriteLine("Querying Middle 100 Documents");
              var found = monkies.Where(x => x.ID > 100 && x.ID < 500);
              sw.Stop();
              Console.WriteLine("Queried {0} documents in {1}ms", found.Count(), sw.ElapsedMilliseconds);
        }
        public void Removes_Range_From_List()
        {
            int INSERT_QTY = 100;
            var batch      = new List <Widget>();

            for (int i = 0; i < INSERT_QTY; i++)
            {
                batch.Add(new Widget {
                    SKU = string.Format("00{0}", i), Name = string.Format("Test widget {0}", i), Price = 2.00M + i
                });
            }
            _biggyList.Add(batch);

            var itemsToRemove = _biggyList.Where(w => w.Price > 5 && w.Price <= 20).ToList();
            int removedQty    = itemsToRemove.Count;

            _biggyList.Remove(itemsToRemove);
            var remaining = _biggyList.ToList();

            Assert.True(removedQty > 0 && removedQty < INSERT_QTY && remaining.Count == (INSERT_QTY - removedQty));
        }
Exemple #11
0
        //static void WhatWhat() {

        //  var sw = new Stopwatch();
        //  sw.Start();
        //  var products = new MassiveList<NWProduct>(connectionStringName: "northwind", tableName: "products", primaryKeyName: "productid");
        //  sw.Stop();
        //  Console.WriteLine("Read " + products.Count + " into memory in " + sw.ElapsedMilliseconds + "ms");
        //  foreach (var p in products) {
        //    Console.WriteLine(p.Sku);
        //  }

        //  sw.Reset();
        //  sw.Start();
        //  var readOne = products.FirstOrDefault(x => x.ProductName == "Product24");
        //  Console.WriteLine(readOne.ProductName);
        //  sw.Stop();

        //  Console.WriteLine("Read single in " + sw.ElapsedMilliseconds + "ms");
        //  sw.Reset();
        //  sw.Start();
        //  var details = new MassiveList<OrderDetail>(connectionStringName: "northwind", tableName: "orderdetails", primaryKeyName: "orderdetailid");
        //  sw.Stop();

        //  Console.WriteLine("Read " + details.Count + " into memory in " + sw.ElapsedMilliseconds + "ms");


        //  Console.Read();
        //}

        static void RunBenchmarks()
        {
            Console.WriteLine("Writing 1000 records sync");
            var products = new BiggyList <Product>();

            products.Clear();
            //File.Delete(products.DbPath);
            //products.Reload();
            //1000 writes?
            var sw = new Stopwatch();

            sw.Start();

            for (int i = 0; i < 1000; i++)
            {
                var p = new Product {
                    Sku = "SKU" + i, Name = "Steve", Price = 12.00M
                };
                products.Add(p);
            }
            sw.Stop();

            Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
            sw.Reset();

            Console.WriteLine("Reading from records");
            sw.Start();
            var p2 = products.Where(x => x.Sku == "SKU22").FirstOrDefault();

            Console.WriteLine(p2.Sku);
            sw.Stop();
            Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);



            Console.Read();
        }
        public void Biggylist_Adds_Range_Of_Items_To_Sqlite_Store()
        {
            var PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore);
            int initialCount         = PropertyDocumentList.Count;

            var myBatch  = new List <PropertyDocument>();
            int qtyToAdd = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                var newPropertyDocument = new PropertyDocument {
                    Name = "New Apartment " + i, Address = "Some Street in a Lonely Town"
                };
                myBatch.Add(newPropertyDocument);
            }
            PropertyDocumentList.Add(myBatch);

            // Reload from the store:
            PropertyDocumentList = new BiggyList <PropertyDocument>(_PropertyDocumentStore);

            var addedItems = PropertyDocumentList.Where(p => p.Id > 0);

            Assert.IsTrue(initialCount == 0 && addedItems.Count() > 0);
        }
Exemple #13
0
        //static void WhatWhat() {
        //  var sw = new Stopwatch();
        //  sw.Start();
        //  var products = new MassiveList<NWProduct>(connectionStringName: "northwind", tableName: "products", primaryKeyName: "productid");
        //  sw.Stop();
        //  Console.WriteLine("Read " + products.Count + " into memory in " + sw.ElapsedMilliseconds + "ms");
        //  foreach (var p in products) {
        //    Console.WriteLine(p.Sku);
        //  }
        //  sw.Reset();
        //  sw.Start();
        //  var readOne = products.FirstOrDefault(x => x.ProductName == "Product24");
        //  Console.WriteLine(readOne.ProductName);
        //  sw.Stop();
        //  Console.WriteLine("Read single in " + sw.ElapsedMilliseconds + "ms");
        //  sw.Reset();
        //  sw.Start();
        //  var details = new MassiveList<OrderDetail>(connectionStringName: "northwind", tableName: "orderdetails", primaryKeyName: "orderdetailid");
        //  sw.Stop();
        //  Console.WriteLine("Read " + details.Count + " into memory in " + sw.ElapsedMilliseconds + "ms");
        //  Console.Read();
        //}
        static void RunBenchmarks()
        {
            Console.WriteLine("Writing 1000 records sync");
              var sw = new Stopwatch();
              var products = new BiggyList<Product>();

              //1000 writes?
              for (int i = 0; i < 1000; i++) {
            var p = new Product { Sku = "SKU" + i, Name = "Steve", Price = 12.00M };
            products.Add(p);
              }
              sw.Start();
              products.Save();
              sw.Stop();

              Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
              sw.Reset();

              Console.WriteLine("Resetting...");
              products.Purge();

              Console.WriteLine("Writing 1000 records async");

              //1000 writes?
              for (int i = 0; i < 1000; i++) {
            var p = new Product { Sku = "SKUDDY" + i, Name = "Steve", Price = 12.00M };
            products.Add(p);
              }
              sw.Start();
              products.SaveAsync();
              sw.Stop();

              Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
              sw.Reset();

              //1000 writes?
              Console.WriteLine("Writing 1000 records with write happening in a loop");

              sw.Start();
              for (int i = 0; i < 1000; i++) {
            var p = new Product { Sku = "SKU" + i, Name = "Steve", Price = 12.00M };
            products.Add(p);
            //bad idea... run it and see why
            products.Save();
              }
              sw.Stop();

              Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
              sw.Reset();

              Console.WriteLine("Reading from records");
              sw.Start();
              var p2 = products.Where(x => x.Sku == "SKU22").FirstOrDefault();
              Console.WriteLine(p2.Sku);
              sw.Stop();
              Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);

              Console.Read();
        }
Exemple #14
0
 public IEnumerable <ShortenedUrl> GetUserSites(string userID)
 {
     return(db.Where(x => x.CreatedBy.Equals(userID)));
 }
    public void Biggylist_Updates_Range_Of_Items_In_Json_Store() {
      var propertyList = new BiggyList<Property>(_propertyStore);
      int initialCount = propertyList.Count;

      var myBatch = new List<Property>();
      int qtyToAdd = 10;

      // This test uses an initial index value of 1 so taht there is a non-zero ID for the first item:
      for (int i = 1; i <= qtyToAdd; i++) {
        myBatch.Add(new Property { Id = i, Name = "John's Luxury Townhomes" + i, Address = i + " Property Parkway, Portland, OR 97204" });
      }
      propertyList.Add(myBatch);

      // Just to be sure, reload from backing store and check what was added:
      propertyList = new BiggyList<Property>(_propertyStore);
      int addedCount = propertyList.Count;

      // Update each item:
      for (int i = 0; i < qtyToAdd; i++) {
        propertyList.ElementAt(i).Name = "John's Low-Rent Brick Homes " + i;
      }
      propertyList.Update(propertyList.ToList());

      // Reload, and check updated names:
      propertyList = new BiggyList<Property>(_propertyStore);
      var updatedItems = propertyList.Where(p => p.Name.Contains("Low-Rent Brick"));
      Assert.IsTrue(updatedItems.Count() == qtyToAdd);
    }
    public void Biggylist_Removes_Range_Of_Items_From_Json_Store() {
      var propertyList = new BiggyList<Property>(_propertyStore);
      int initialCount = propertyList.Count;

      var myBatch = new List<Property>();
      int qtyToAdd = 10;

      // This test uses an initial index value of 1 so taht there is a non-zero ID for the first item:
      for (int i = 1; i <= qtyToAdd; i++) {
        myBatch.Add(new Property { Id = i, Name = "Boardwalk " + i, Address = i + " Property Parkway, Portland, OR 97204" });
      }
      propertyList.Add(myBatch);

      // Re-load from back-end:
      propertyList = new BiggyList<Property>(_propertyStore);
      int qtyAdded = propertyList.Count;

      // Select 5 for deletion:
      int qtyToDelete = 5;
      var deleteThese = propertyList.Where(c => c.Id <= qtyToDelete);
      propertyList.Remove(deleteThese);

      // Delete:
      propertyList = new BiggyList<Property>(_propertyStore);
      int remaining = propertyList.Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
    }
Exemple #17
0
        public static void Run()
        {
            var sw = new Stopwatch();
              Console.WriteLine("===========================================================");
              Console.WriteLine("Postgres - SOME FANCY QUERYING");
              Console.WriteLine("===========================================================");

              var _db = new PGCache(_connectionStringName);
              IBiggy<Artist> _artists;
              IBiggy<Album> _albums;
              IBiggy<Track> _tracks;

              Console.WriteLine("Loading up Artists from Chinook...");
              sw.Start();
              _artists = new BiggyList<Artist>(new PGStore<Artist>(_db));
              sw.Stop();
              Console.WriteLine("\tLoaded {0} Artist records in {1} ms", _artists.Count(), sw.ElapsedMilliseconds);

              Console.WriteLine("Loading up Albums from Chinook...");
              sw.Reset();
              sw.Start();
              _albums = new BiggyList<Album>(new PGStore<Album>(_db));
              sw.Stop();
              Console.WriteLine("\tLoaded {0} Albums in {1} ms", _artists.Count(), sw.ElapsedMilliseconds);

              Console.WriteLine("Loading up tracks from Chinook...");
              sw.Reset();
              sw.Start();
              _tracks = new BiggyList<Track>(new PGStore<Track>(_db));
              sw.Stop();
              Console.WriteLine("\tLoaded {0} Tracks in {1} ms", _tracks.Count(), sw.ElapsedMilliseconds);

              Console.WriteLine("Grab the record for AC/DC...");
              sw.Reset();
              sw.Start();
              var acdc = _artists.FirstOrDefault(a => a.Name == "AC/DC");
              sw.Stop();
              Console.WriteLine("\tFound AC/DC from memory in {0} ms", sw.ElapsedMilliseconds);

              Console.WriteLine("Find all the albums by AC/DC ...");
              sw.Reset();
              sw.Start();
              var acdcAlbums = _albums.Where(a => a.ArtistId == acdc.ArtistId);
              sw.Stop();
              Console.WriteLine("\tFound All {0} AC/DC albums from memory in {1} ms", acdcAlbums.Count(), sw.ElapsedMilliseconds);

              Console.WriteLine("Find all the Tracks from Albums by AC/DC ...");
              sw.Reset();
              sw.Start();
              var acdcTracks = from t in _tracks
                       join a in acdcAlbums on t.AlbumId equals a.AlbumId
                       select t;
              sw.Stop();
              Console.WriteLine("\tFound All {0} tracks by ACDC using in-memory JOIN in {1} ms:", acdcTracks.Count(), sw.ElapsedMilliseconds);
              foreach (var track in acdcTracks)
              {
            Console.WriteLine("\t-{0}", track.Name);
              }
              Console.WriteLine(Environment.NewLine);
              Console.WriteLine("===========================================================");
              Console.WriteLine("POSTGES - BASIC CRUD OPERATIONS");
              Console.WriteLine("===========================================================");

              IBiggy<Customer> _customers;

              sw.Reset();
              Console.WriteLine("Loading up customers from Chinook...");
              sw.Start();
              _customers = new BiggyList<Customer>(new PGStore<Customer>(_db));
              sw.Stop();
              Console.WriteLine("\tLoaded {0} records in {1}ms", _customers.Count(), sw.ElapsedMilliseconds);

              sw.Reset();
              Console.WriteLine("INSERTING a NEW Customer into Chinook...");
              var newCustomer = new Customer() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" };
              sw.Start();
              _customers.Add(newCustomer);
              sw.Stop();
              Console.WriteLine("\tWrote 1 record for a new count of {0} records in {1} ms", _customers.Count(), sw.ElapsedMilliseconds);

              sw.Reset();
              Console.WriteLine("UPDATING the new Customer record in Chinook...");
              newCustomer.FirstName = "Fred";
              sw.Start();
              _customers.Update(newCustomer);
              sw.Stop();
              Console.WriteLine("\tUpdated 1 record for a new count of {0} records in {1} ms", _customers.Count(), sw.ElapsedMilliseconds);

              sw.Reset();
              Console.WriteLine("DELETE the new Customer record in Chinook...");
              sw.Start();
              _customers.Remove(newCustomer);
              sw.Stop();
              Console.WriteLine("\tDeleted 1 record for a new count of {0} records in {1} ms", _customers.Count(), sw.ElapsedMilliseconds);

              Console.WriteLine(Environment.NewLine);
              Console.WriteLine("===========================================================");
              Console.WriteLine("POSTGES - BULK INSERTS AND DELETIONS");
              Console.WriteLine("===========================================================");

              Console.WriteLine("Creating Test Table...");
              if(_db.TableExists("client"))
              {
            _db.DropTable("client");
              }
              var columnDefs = new List<string>();
              columnDefs.Add("client_id serial PRIMARY KEY NOT NULL");
              columnDefs.Add("last_name Text NOT NULL");
              columnDefs.Add("first_name Text NOT NULL");
              columnDefs.Add("email Text NOT NULL");
              _db.CreateTable("client", columnDefs);

              IBiggy<Client> _clients;

              sw.Reset();
              int INSERT_QTY = 10000;
              Console.WriteLine("BULK INSERTING  {0} client records in Chinook...", INSERT_QTY);
              _clients = new BiggyList<Client>(new PGStore<Client>(_db));

              var inserts = new List<Client>();
              for (int i = 0; i < INSERT_QTY; i++)
              {
            inserts.Add(new Client() { LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**" });
              }
              sw.Start();
              var inserted = _clients.Add(inserts);
              sw.Stop();
              Console.WriteLine("\tInserted {0} records in {1} ms", inserted.Count(), sw.ElapsedMilliseconds);

              sw.Reset();
              Console.WriteLine("Loading up Bulk inserted CLients from Chinook...");
              sw.Start();
              _clients = new BiggyList<Client>(new PGStore<Client>(_db));
              sw.Stop();
              Console.WriteLine("\tLoaded {0} records in {1}ms", _clients.Count(), sw.ElapsedMilliseconds);

              sw.Reset();
              Console.WriteLine("DELETING added records from Chinook...");
              var toRemove = _clients.Where(x => x.Email == "*****@*****.**");
              sw.Start();
              var removed = _clients.Remove(toRemove.ToList());
              sw.Stop();
              Console.WriteLine("\tDeleted {0} records in {1}ms", removed.Count(), sw.ElapsedMilliseconds);
        }
Exemple #18
0
        public static void Run()
        {
            var sw = new Stopwatch();

            Console.WriteLine("===========================================================");
            Console.WriteLine("Postgres - SOME FANCY QUERYING");
            Console.WriteLine("===========================================================");


            var             _db = new PGCache(_connectionStringName);
            IBiggy <Artist> _artists;
            IBiggy <Album>  _albums;
            IBiggy <Track>  _tracks;

            Console.WriteLine("Loading up Artists from Chinook...");
            sw.Start();
            _artists = new BiggyList <Artist>(new PGStore <Artist>(_db));
            sw.Stop();
            Console.WriteLine("\tLoaded {0} Artist records in {1} ms", _artists.Count(), sw.ElapsedMilliseconds);


            Console.WriteLine("Loading up Albums from Chinook...");
            sw.Reset();
            sw.Start();
            _albums = new BiggyList <Album>(new PGStore <Album>(_db));
            sw.Stop();
            Console.WriteLine("\tLoaded {0} Albums in {1} ms", _artists.Count(), sw.ElapsedMilliseconds);


            Console.WriteLine("Loading up tracks from Chinook...");
            sw.Reset();
            sw.Start();
            _tracks = new BiggyList <Track>(new PGStore <Track>(_db));
            sw.Stop();
            Console.WriteLine("\tLoaded {0} Tracks in {1} ms", _tracks.Count(), sw.ElapsedMilliseconds);


            Console.WriteLine("Grab the record for AC/DC...");
            sw.Reset();
            sw.Start();
            var acdc = _artists.FirstOrDefault(a => a.Name == "AC/DC");

            sw.Stop();
            Console.WriteLine("\tFound AC/DC from memory in {0} ms", sw.ElapsedMilliseconds);


            Console.WriteLine("Find all the albums by AC/DC ...");
            sw.Reset();
            sw.Start();
            var acdcAlbums = _albums.Where(a => a.ArtistId == acdc.ArtistId);

            sw.Stop();
            Console.WriteLine("\tFound All {0} AC/DC albums from memory in {1} ms", acdcAlbums.Count(), sw.ElapsedMilliseconds);

            Console.WriteLine("Find all the Tracks from Albums by AC/DC ...");
            sw.Reset();
            sw.Start();
            var acdcTracks = from t in _tracks
                             join a in acdcAlbums on t.AlbumId equals a.AlbumId
                             select t;

            sw.Stop();
            Console.WriteLine("\tFound All {0} tracks by ACDC using in-memory JOIN in {1} ms:", acdcTracks.Count(), sw.ElapsedMilliseconds);
            foreach (var track in acdcTracks)
            {
                Console.WriteLine("\t-{0}", track.Name);
            }
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("===========================================================");
            Console.WriteLine("POSTGES - BASIC CRUD OPERATIONS");
            Console.WriteLine("===========================================================");

            IBiggy <Customer> _customers;


            sw.Reset();
            Console.WriteLine("Loading up customers from Chinook...");
            sw.Start();
            _customers = new BiggyList <Customer>(new PGStore <Customer>(_db));
            sw.Stop();
            Console.WriteLine("\tLoaded {0} records in {1}ms", _customers.Count(), sw.ElapsedMilliseconds);

            sw.Reset();
            Console.WriteLine("INSERTING a NEW Customer into Chinook...");
            var newCustomer = new Customer()
            {
                LastName = "Atten", FirstName = "John", Email = "*****@*****.**"
            };

            sw.Start();
            _customers.Add(newCustomer);
            sw.Stop();
            Console.WriteLine("\tWrote 1 record for a new count of {0} records in {1} ms", _customers.Count(), sw.ElapsedMilliseconds);

            sw.Reset();
            Console.WriteLine("UPDATING the new Customer record in Chinook...");
            newCustomer.FirstName = "Fred";
            sw.Start();
            _customers.Update(newCustomer);
            sw.Stop();
            Console.WriteLine("\tUpdated 1 record for a new count of {0} records in {1} ms", _customers.Count(), sw.ElapsedMilliseconds);

            sw.Reset();
            Console.WriteLine("DELETE the new Customer record in Chinook...");
            sw.Start();
            _customers.Remove(newCustomer);
            sw.Stop();
            Console.WriteLine("\tDeleted 1 record for a new count of {0} records in {1} ms", _customers.Count(), sw.ElapsedMilliseconds);


            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("===========================================================");
            Console.WriteLine("POSTGES - BULK INSERTS AND DELETIONS");
            Console.WriteLine("===========================================================");

            Console.WriteLine("Creating Test Table...");
            if (_db.TableExists("client"))
            {
                _db.DropTable("client");
            }
            var columnDefs = new List <string>();

            columnDefs.Add("client_id serial PRIMARY KEY NOT NULL");
            columnDefs.Add("last_name Text NOT NULL");
            columnDefs.Add("first_name Text NOT NULL");
            columnDefs.Add("email Text NOT NULL");
            _db.CreateTable("client", columnDefs);

            IBiggy <Client> _clients;

            sw.Reset();
            int INSERT_QTY = 10000;

            Console.WriteLine("BULK INSERTING  {0} client records in Chinook...", INSERT_QTY);
            _clients = new BiggyList <Client>(new PGStore <Client>(_db));

            var inserts = new List <Client>();

            for (int i = 0; i < INSERT_QTY; i++)
            {
                inserts.Add(new Client()
                {
                    LastName = string.Format("Atten {0}", i.ToString()), FirstName = "John", Email = "*****@*****.**"
                });
            }
            sw.Start();
            var inserted = _clients.Add(inserts);

            sw.Stop();
            Console.WriteLine("\tInserted {0} records in {1} ms", inserted.Count(), sw.ElapsedMilliseconds);

            sw.Reset();
            Console.WriteLine("Loading up Bulk inserted CLients from Chinook...");
            sw.Start();
            _clients = new BiggyList <Client>(new PGStore <Client>(_db));
            sw.Stop();
            Console.WriteLine("\tLoaded {0} records in {1}ms", _clients.Count(), sw.ElapsedMilliseconds);


            sw.Reset();
            Console.WriteLine("DELETING added records from Chinook...");
            var toRemove = _clients.Where(x => x.Email == "*****@*****.**");

            sw.Start();
            var removed = _clients.Remove(toRemove.ToList());

            sw.Stop();
            Console.WriteLine("\tDeleted {0} records in {1}ms", removed.Count(), sw.ElapsedMilliseconds);
        }
        public IHttpActionResult GetBlogLogging()
        {
            var logitems = BlogLogs.Where(x => Convert.ToDateTime(x.Date) > DateTime.Now.AddDays(-5)).ToList();

            return(Ok(logitems));
        }
Exemple #20
0
        static void Main(string[] args)
        {
            Console.WriteLine("Writing 1000 records sync");
            var sw       = new Stopwatch();
            var products = new BiggyList <Product>();

            //1000 writes?
            for (int i = 0; i < 1000; i++)
            {
                var p = new Product {
                    Sku = "SKU" + i, Name = "Steve", Price = 12.00M
                };
                products.Add(p);
            }
            sw.Start();
            products.Save();
            sw.Stop();

            Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
            sw.Reset();

            Console.WriteLine("Resetting...");
            products.ClearAndSave();

            Console.WriteLine("Writing 1000 records async");

            //1000 writes?
            for (int i = 0; i < 1000; i++)
            {
                var p = new Product {
                    Sku = "SKUDDY" + i, Name = "Steve", Price = 12.00M
                };
                products.Add(p);
            }
            sw.Start();
            products.SaveAsync();
            sw.Stop();

            Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
            sw.Reset();


            //1000 writes?
            Console.WriteLine("Writing 1000 records with write happening in a loop");

            sw.Start();
            for (int i = 0; i < 1000; i++)
            {
                var p = new Product {
                    Sku = "SKU" + i, Name = "Steve", Price = 12.00M
                };
                products.Add(p);
                //bad idea... run it and see why
                products.Save();
            }
            sw.Stop();

            Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);
            sw.Reset();


            Console.WriteLine("Reading from records");
            sw.Start();
            var p2 = products.Where(x => x.Sku == "SKU22").FirstOrDefault();

            Console.WriteLine(p2.Sku);
            sw.Stop();
            Console.WriteLine("{0}ms", sw.ElapsedMilliseconds);



            Console.Read();
        }
    public void Biggylist_Updates_Range_Of_Items_In_Sqlite_Store() {
      var PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore);
      int initialCount = PropertyDocumentList.Count;

      var myBatch = new List<PropertyDocument>();
      int qtyToAdd = 10;
      for (int i = 1; i <= qtyToAdd; i++) {
        myBatch.Add(new PropertyDocument { Name = "John's Luxury Townhomes" + i, Address = i + " PropertyDocument Parkway, Portland, OR 97204" });
      }
      PropertyDocumentList.Add(myBatch);

      // Just to be sure, reload from backing store and check what was added:
      PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore);
      int addedCount = PropertyDocumentList.Count;

      // Update each item:
      for (int i = 0; i < qtyToAdd; i++) {
        PropertyDocumentList.ElementAt(i).Name = "John's Low-Rent Brick Homes " + i;
      }
      PropertyDocumentList.Update(PropertyDocumentList.ToList());

      // Reload, and check updated names:
      PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore);
      var updatedItems = PropertyDocumentList.Where(p => p.Name.Contains("Low-Rent Brick"));
      Assert.IsTrue(updatedItems.Count() == qtyToAdd);
    }
    public void Biggylist_Removes_Range_Of_Items_From_Sqlite_Store() {
      var PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore);
      int initialCount = PropertyDocumentList.Count;

      var myBatch = new List<PropertyDocument>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        myBatch.Add(new PropertyDocument { Name = "Boardwalk " + i, Address = i + " PropertyDocument Parkway, Portland, OR 97204" });
      }
      PropertyDocumentList.Add(myBatch);

      // Re-load from back-end:
      PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore);
      int qtyAdded = PropertyDocumentList.Count;

      // Select 5 for deletion:
      int qtyToDelete = 5;
      var deleteThese = PropertyDocumentList.Where(c => c.Id <= qtyToDelete);
      PropertyDocumentList.Remove(deleteThese);

      // Delete:
      PropertyDocumentList = new BiggyList<PropertyDocument>(_PropertyDocumentStore);
      int remaining = PropertyDocumentList.Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
    }