public void Relational_Store_Deletes_range_of_records_with_name_attributes()
        {
            var WorkOrderStore = new SqliteRelationalStore <WorkOrder>(_db);
            var myBatch        = new List <WorkOrder>();
            int qtyToAdd       = 10;

            for (int i = 0; i < qtyToAdd; i++)
            {
                var newWorkOrder = new WorkOrder {
                    Description = "Kill mice dead " + i
                };
                myBatch.Add(newWorkOrder);
            }
            WorkOrderStore.Add(myBatch);

            // Re-load from back-end:
            var workOrders = WorkOrderStore.TryLoadData();
            int qtyAdded   = workOrders.Count;

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

            // Delete:
            WorkOrderStore.Delete(deleteThese);
            int remaining = WorkOrderStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
        }
Esempio n. 2
0
        public void Relational_Store_Updates_range_of_records_with_pg_names()
        {
            var UnitStore = new SqliteRelationalStore <Unit>(_db);
            var myBatch   = new List <Unit>();
            int qtyToAdd  = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                var newUnit = new Unit {
                    BIN = "OR06-" + i, UnitNo = "D-10" + i
                };
                myBatch.Add(newUnit);
            }
            UnitStore.Add(myBatch);

            // Re-load, and update:
            var companies = UnitStore.TryLoadData();

            for (int i = 0; i < qtyToAdd; i++)
            {
                companies.ElementAt(i).UnitNo = "Updated-50" + i;
            }
            UnitStore.Update(companies);

            // Reload, and check updated names:
            companies = UnitStore.TryLoadData().Where(c => c.UnitNo.Contains("Updated")).ToList();
            Assert.IsTrue(companies.Count == qtyToAdd);
        }
        public void Relational_Store_Updates_range_of_records_with_serial_id()
        {
            var PropertyStore = new SqliteRelationalStore <Property>(_db);
            var myBatch       = new List <Property>();
            int qtyToAdd      = 10;

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

            // Re-load, and update:
            var companies = PropertyStore.TryLoadData();

            for (int i = 0; i < qtyToAdd; i++)
            {
                companies.ElementAt(i).Name = "John's Low-Rent Brick Homes " + i;
            }
            PropertyStore.Update(companies);

            // Reload, and check updated names:
            companies = PropertyStore.TryLoadData().Where(c => c.Name.Contains("Low-Rent")).ToList();
            Assert.IsTrue(companies.Count == qtyToAdd);
        }
        public void Relational_Store_Deletes_all_records_with_name_attributes()
        {
            var WorkOrderStore = new SqliteRelationalStore <WorkOrder>(_db);
            var myBatch        = new List <WorkOrder>();
            int qtyToAdd       = 10;

            for (int i = 0; i < qtyToAdd; i++)
            {
                var newWorkOrder = new WorkOrder {
                    Description = "Kill Roaches dead " + i
                };
                myBatch.Add(newWorkOrder);
            }
            WorkOrderStore.Add(myBatch);

            // Re-load from back-end:
            var workOrders = WorkOrderStore.TryLoadData();
            int qtyAdded   = workOrders.Count;

            // Delete:
            WorkOrderStore.DeleteAll();
            int remaining = WorkOrderStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
        }
        public void Relational_Store_Updates_range_of_records_with_name_attributes()
        {
            var WorkOrderStore = new SqliteRelationalStore <WorkOrder>(_db);
            var myBatch        = new List <WorkOrder>();
            int qtyToAdd       = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                var newWorkOrder = new WorkOrder {
                    Description = "Caulk Tub " + i
                };
                myBatch.Add(newWorkOrder);
            }
            WorkOrderStore.Add(myBatch);

            // Re-load, and update:
            var workOrders = WorkOrderStore.TryLoadData();

            for (int i = 0; i < qtyToAdd; i++)
            {
                workOrders.ElementAt(i).Description = "Updated Tubs" + i;
            }
            WorkOrderStore.Update(workOrders);

            // Reload, and check updated names:
            workOrders = WorkOrderStore.TryLoadData().Where(c => c.Description.Contains("Updated")).ToList();
            Assert.IsTrue(workOrders.Count == qtyToAdd);
        }
Esempio n. 6
0
        public void Relational_Store_Deletes_all_records_with_string_id()
        {
            var BuildingStore = new SqliteRelationalStore <Building>(_db);
            var myBatch       = new List <Building>();
            int qtyToAdd      = 10;

            for (int i = 0; i < qtyToAdd; i++)
            {
                var newBuilding = new Building {
                    BIN = "OR500-" + i, Identifier = "Building " + i, PropertyId = i
                };
                myBatch.Add(newBuilding);
            }
            BuildingStore.Add(myBatch);

            // Re-load from back-end:
            var buildings = BuildingStore.TryLoadData();
            int qtyAdded  = buildings.Count;

            // Delete:
            BuildingStore.DeleteAll();
            int remaining = BuildingStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
        }
Esempio n. 7
0
        public void Relational_Store_Deletes_all_records_with_pg_names()
        {
            var UnitStore = new SqliteRelationalStore <Unit>(_db);
            var myBatch   = new List <Unit>();
            int qtyToAdd  = 10;

            for (int i = 0; i < qtyToAdd; i++)
            {
                var newUnit = new Unit {
                    BIN = "OR09-" + i, UnitNo = "G-10" + i
                };
                myBatch.Add(newUnit);
            }
            UnitStore.Add(myBatch);

            // Re-load from back-end:
            var companies = UnitStore.TryLoadData();
            int qtyAdded  = companies.Count;

            // Delete:
            UnitStore.DeleteAll();
            int remaining = UnitStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
        }
Esempio n. 8
0
        public void Relational_Store_Updates_range_of_records_with_string_id()
        {
            var BuildingStore = new SqliteRelationalStore <Building>(_db);
            var myBatch       = new List <Building>();
            int qtyToAdd      = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                var newBuilding = new Building {
                    BIN = "OR13-" + i, Identifier = "Building " + i, PropertyId = i
                };
                myBatch.Add(newBuilding);
            }
            BuildingStore.Add(myBatch);

            // Re-load, and update:
            var buildings = BuildingStore.TryLoadData();

            for (int i = 0; i < qtyToAdd; i++)
            {
                buildings.ElementAt(i).Identifier = "Updated Building " + i;
            }
            BuildingStore.Update(buildings);

            // Reload, and check updated names:
            buildings = BuildingStore.TryLoadData().Where(c => c.Identifier.Contains("Updated")).ToList();
            Assert.IsTrue(buildings.Count == qtyToAdd);
        }
Esempio n. 9
0
        public void Relational_Store_Deletes_range_of_records_with_string_id()
        {
            var BuildingStore = new SqliteRelationalStore <Building>(_db);
            var myBatch       = new List <Building>();
            int qtyToAdd      = 10;

            for (int i = 0; i < qtyToAdd; i++)
            {
                var newBuilding = new Building {
                    BIN = "OR400-" + i, Identifier = "Building " + i, PropertyId = i
                };
                myBatch.Add(newBuilding);
            }
            BuildingStore.Add(myBatch);

            // Re-load from back-end:
            var buildings = BuildingStore.TryLoadData();
            int qtyAdded  = buildings.Count;

            // Select 5 for deletion:
            int qtyToDelete = 5;
            var deleteThese = new List <Building>();

            for (int i = 0; i < qtyToDelete; i++)
            {
                deleteThese.Add(buildings.ElementAt(i));
            }

            // Delete:
            BuildingStore.Delete(deleteThese);
            int remaining = BuildingStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
        }
Esempio n. 10
0
        public void Relational_Store_Deletes_range_of_records_with_pg_names()
        {
            var UnitStore = new SqliteRelationalStore <Unit>(_db);
            var myBatch   = new List <Unit>();
            int qtyToAdd  = 10;

            for (int i = 0; i < qtyToAdd; i++)
            {
                var newUnit = new Unit {
                    BIN = "OR08-" + i, UnitNo = "F-10" + i
                };
                myBatch.Add(newUnit);
            }
            UnitStore.Add(myBatch);

            // Re-load from back-end:
            var companies = UnitStore.TryLoadData();
            int qtyAdded  = companies.Count;

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

            // Delete:
            UnitStore.Delete(deleteThese);
            int remaining = UnitStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
        }
        public void Relational_Store_Deletes_range_of_records_with_serial_id()
        {
            var PropertyStore = new SqliteRelationalStore <Property>(_db);
            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"
                });
            }
            PropertyStore.Add(myBatch);

            // Re-load from back-end:
            var companies = PropertyStore.TryLoadData();
            int qtyAdded  = companies.Count;

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

            // Delete:
            PropertyStore.Delete(deleteThese);
            int remaining = PropertyStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
        }
    public void Relational_Store_Updates_record_with_string_id() {
      var BuildingStore = new SqliteRelationalStore<Building>(_db);
      var newBuilding = new Building { BIN = "OR13-55", Identifier = "Building C", PropertyId = 1 };
      BuildingStore.Add(newBuilding);

      // Now go fetch the record again and update:
      string newIdentifier = "Updated Building C";
      var foundBuilding = BuildingStore.TryLoadData().FirstOrDefault();
      foundBuilding.Identifier = newIdentifier;
      BuildingStore.Update(foundBuilding);

      foundBuilding = BuildingStore.TryLoadData().FirstOrDefault(b => b.BIN == "OR13-55");
      Assert.IsTrue(foundBuilding != null && foundBuilding.Identifier == newIdentifier);
    }
    public void Relational_Store_Updates_record_with_name_attributes() {
      var WorkOrderStore = new SqliteRelationalStore<WorkOrder>(_db);
      var newWorkOrder = new WorkOrder { Description = "Snake toilet" };
      WorkOrderStore.Add(newWorkOrder);

      // Now go fetch the record again and update:
      string newValue = "Update: Call Roto-Rooter";
      var foundWorkOrder = WorkOrderStore.TryLoadData().FirstOrDefault();
      foundWorkOrder.Description = newValue;
      WorkOrderStore.Update(foundWorkOrder);

      foundWorkOrder = WorkOrderStore.TryLoadData().FirstOrDefault();
      Assert.IsTrue(foundWorkOrder != null && foundWorkOrder.Description == newValue);
    }
    public void Relational_Store_Updates_record_with_serial_id() {
      var PropertyStore = new SqliteRelationalStore<Property>(_db);
      var newProperty = new Property { Name = "John's Luxury Apartments", Address = "16 Property Parkway, Portland, OR 97204" };
      PropertyStore.Add(newProperty);

      // Now go fetch the record again and update:
      string newName = "John's Low-Rent Apartments";
      var foundProperty = PropertyStore.TryLoadData().FirstOrDefault();

      int idToFind = foundProperty.Id;
      foundProperty.Name = newName;
      PropertyStore.Update(foundProperty);
      foundProperty = PropertyStore.TryLoadData().FirstOrDefault(p => p.Id == idToFind);

      Assert.IsTrue(foundProperty != null && foundProperty.Name == newName);
    }
    public void Relational_Store_Inserts_record_with_pg_names() {
      var UnitStore = new SqliteRelationalStore<Unit>(_db);
      var newUnit = new Unit { BIN = "OR03-01", UnitNo = "A-101" };
      UnitStore.Add(newUnit);

      var foundUnit = UnitStore.TryLoadData().FirstOrDefault();
      Assert.IsTrue(foundUnit != null && foundUnit.UnitId == 1);
    }
    public void Relational_Store_Inserts_record_with_serial_id() {
      var propertyStore = new SqliteRelationalStore<Property>(_db);
      var newProperty = new Property { Name = "Watergate Apartments", Address = "2639 I St NW, Washington, D.C. 20037" };
      propertyStore.Add(newProperty);

      var foundProperty = propertyStore.TryLoadData().FirstOrDefault();
      Assert.IsTrue(foundProperty != null && foundProperty.Id == 1);
    }
    public void Relational_Store_Inserts_record_with_name_attributes() {
      var WorkOrderStore = new SqliteRelationalStore<WorkOrder>(_db);
      var newWorkOrder = new WorkOrder { Description = "Take out the Trash" };
      WorkOrderStore.Add(newWorkOrder);

      var foundWorkOrder = WorkOrderStore.TryLoadData().FirstOrDefault();
      Assert.IsTrue(foundWorkOrder != null && foundWorkOrder.WorkOrderId == 1);
    }
    public void Relational_Store_Inserts_record_with_string_id() {
      var theBin = "OR13-22";
      var BuildingStore = new SqliteRelationalStore<Building>(_db);
      var newBuilding = new Building { BIN = "OR13-22", Identifier = "Building A", PropertyId = 1 };
      BuildingStore.Add(newBuilding);

      var foundBuilding = BuildingStore.TryLoadData().FirstOrDefault();
      Assert.IsTrue(foundBuilding != null && foundBuilding.BIN == theBin);
    }
Esempio n. 19
0
        public void Relational_Store_Updates_record_with_string_id()
        {
            var BuildingStore = new SqliteRelationalStore <Building>(_db);
            var newBuilding   = new Building {
                BIN = "OR13-55", Identifier = "Building C", PropertyId = 1
            };

            BuildingStore.Add(newBuilding);

            // Now go fetch the record again and update:
            string newIdentifier = "Updated Building C";
            var    foundBuilding = BuildingStore.TryLoadData().FirstOrDefault();

            foundBuilding.Identifier = newIdentifier;
            BuildingStore.Update(foundBuilding);

            foundBuilding = BuildingStore.TryLoadData().FirstOrDefault(b => b.BIN == "OR13-55");
            Assert.IsTrue(foundBuilding != null && foundBuilding.Identifier == newIdentifier);
        }
        public void Relational_Store_Updates_record_with_name_attributes()
        {
            var WorkOrderStore = new SqliteRelationalStore <WorkOrder>(_db);
            var newWorkOrder   = new WorkOrder {
                Description = "Snake toilet"
            };

            WorkOrderStore.Add(newWorkOrder);

            // Now go fetch the record again and update:
            string newValue       = "Update: Call Roto-Rooter";
            var    foundWorkOrder = WorkOrderStore.TryLoadData().FirstOrDefault();

            foundWorkOrder.Description = newValue;
            WorkOrderStore.Update(foundWorkOrder);

            foundWorkOrder = WorkOrderStore.TryLoadData().FirstOrDefault();
            Assert.IsTrue(foundWorkOrder != null && foundWorkOrder.Description == newValue);
        }
 public void Relational_Store_Inserts_range_of_records_with_name_attributes() {
   var WorkOrderStore = new SqliteRelationalStore<WorkOrder>(_db);
   var myBatch = new List<WorkOrder>();
   int qtyToAdd = 10;
   for (int i = 1; i <= qtyToAdd; i++) {
     var newWorkOrder = new WorkOrder { Description = "Replace Lightbulbs " + i };
     myBatch.Add(newWorkOrder);
   }
   WorkOrderStore.Add(myBatch);
   var workOrders = WorkOrderStore.TryLoadData();
   Assert.IsTrue(workOrders.Count == qtyToAdd);
 }
        public void Relational_Store_Updates_record_with_serial_id()
        {
            var PropertyStore = new SqliteRelationalStore <Property>(_db);
            var newProperty   = new Property {
                Name = "John's Luxury Apartments", Address = "16 Property Parkway, Portland, OR 97204"
            };

            PropertyStore.Add(newProperty);

            // Now go fetch the record again and update:
            string newName       = "John's Low-Rent Apartments";
            var    foundProperty = PropertyStore.TryLoadData().FirstOrDefault();

            int idToFind = foundProperty.Id;

            foundProperty.Name = newName;
            PropertyStore.Update(foundProperty);
            foundProperty = PropertyStore.TryLoadData().FirstOrDefault(p => p.Id == idToFind);

            Assert.IsTrue(foundProperty != null && foundProperty.Name == newName);
        }
 public void Relational_Store_Inserts_range_of_records_with_pg_names() {
   var UnitStore = new SqliteRelationalStore<Unit>(_db);
   var myBatch = new List<Unit>();
   int qtyToAdd = 10;
   for (int i = 1; i <= qtyToAdd; i++) {
     var newUnit = new Unit { BIN = "OR04-" + i, UnitNo = "B-10" + i };
     myBatch.Add(newUnit);
   }
   UnitStore.Add(myBatch);
   var companies = UnitStore.TryLoadData();
   Assert.IsTrue(companies.Count == qtyToAdd);
 }
    public void Relational_Store_Updates_record_with_pg_names() {
      var UnitStore = new SqliteRelationalStore<Unit>(_db);
      var newUnit = new Unit { BIN = "OR05-01", UnitNo = "C-101" };
      UnitStore.Add(newUnit);

      // Now go fetch the record again and update:
      string newName = "Updated-401";
      var foundUnit = UnitStore.TryLoadData().FirstOrDefault();
      foundUnit.UnitNo = newName;
      UnitStore.Update(foundUnit);
      Assert.IsTrue(foundUnit != null && foundUnit.UnitNo == newName);
    }
 public void Relational_Store_Inserts_range_of_records_with_string_id() {
   var BuildingStore = new SqliteRelationalStore<Building>(_db);
   var myBatch = new List<Building>();
   int qtyToAdd = 10;
   for (int i = 1; i <= qtyToAdd; i++) {
     var newBuilding = new Building { BIN = "OR13-" + i, Identifier = "Building " + i, PropertyId = i };
     myBatch.Add(newBuilding);
   }
   BuildingStore.Add(myBatch);
   var buildings = BuildingStore.TryLoadData();
   Assert.IsTrue(buildings.Count == qtyToAdd);
 }
 public void Relational_Store_Inserts_range_of_records_with_serial_id() {
   var propertyStore = new SqliteRelationalStore<Property>(_db);
   var myBatch = new List<Property>();
   int qtyToAdd = 10;
   for (int i = 1; i <= qtyToAdd; i++) {
     var newProperty = new Property { Name = "New Apartment " + i, Address = "Some Street in a Lonely Town" };
     myBatch.Add(newProperty);
   }
   propertyStore.Add(myBatch);
   var companies = propertyStore.TryLoadData();
   Assert.IsTrue(companies.Count == qtyToAdd);
 }
Esempio n. 27
0
        public void Relational_Store_Deletes_record_with_pg_names()
        {
            var UnitStore = new SqliteRelationalStore <Unit>(_db);
            var newUnit   = new Unit {
                BIN = "OR07-01", UnitNo = "E-101"
            };

            UnitStore.Add(newUnit);

            // Load from back-end:
            var companies = UnitStore.TryLoadData();
            int qtyAdded  = companies.Count;

            // Delete:
            var foundUnit = companies.FirstOrDefault();

            UnitStore.Delete(foundUnit);

            int remaining = UnitStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == 1 && remaining == 0);
        }
Esempio n. 28
0
        public void Relational_Store_Inserts_record_with_pg_names()
        {
            var UnitStore = new SqliteRelationalStore <Unit>(_db);
            var newUnit   = new Unit {
                BIN = "OR03-01", UnitNo = "A-101"
            };

            UnitStore.Add(newUnit);

            var foundUnit = UnitStore.TryLoadData().FirstOrDefault();

            Assert.IsTrue(foundUnit != null && foundUnit.UnitId == 1);
        }
        public void Relational_Store_Inserts_record_with_name_attributes()
        {
            var WorkOrderStore = new SqliteRelationalStore <WorkOrder>(_db);
            var newWorkOrder   = new WorkOrder {
                Description = "Take out the Trash"
            };

            WorkOrderStore.Add(newWorkOrder);

            var foundWorkOrder = WorkOrderStore.TryLoadData().FirstOrDefault();

            Assert.IsTrue(foundWorkOrder != null && foundWorkOrder.WorkOrderId == 1);
        }
        public void Relational_Store_Deletes_record_with_serial_id()
        {
            var PropertyStore = new SqliteRelationalStore <Property>(_db);
            var newProperty   = new Property {
                Name = "John's High-End Apartments", Address = "16 Property Parkway, Portland, OR 97204"
            };

            PropertyStore.Add(newProperty);

            // Load from back-end:
            var companies = PropertyStore.TryLoadData();
            int qtyAdded  = companies.Count;

            // Delete:
            var foundProperty = companies.FirstOrDefault();

            PropertyStore.Delete(foundProperty);

            int remaining = PropertyStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == 1 && remaining == 0);
        }
        public void Relational_Store_Deletes_record_with_name_attributes()
        {
            var WorkOrderStore = new SqliteRelationalStore <WorkOrder>(_db);
            var newWorkOrder   = new WorkOrder {
                Description = "Eradicate bed bugs"
            };

            WorkOrderStore.Add(newWorkOrder);

            // Load from back-end:
            var workOrders = WorkOrderStore.TryLoadData();
            int qtyAdded   = workOrders.Count;

            // Delete:
            var foundWorkOrder = workOrders.FirstOrDefault();

            WorkOrderStore.Delete(foundWorkOrder);

            int remaining = WorkOrderStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == 1 && remaining == 0);
        }
        public void Relational_Store_Inserts_record_with_serial_id()
        {
            var propertyStore = new SqliteRelationalStore <Property>(_db);
            var newProperty   = new Property {
                Name = "Watergate Apartments", Address = "2639 I St NW, Washington, D.C. 20037"
            };

            propertyStore.Add(newProperty);

            var foundProperty = propertyStore.TryLoadData().FirstOrDefault();

            Assert.IsTrue(foundProperty != null && foundProperty.Id == 1);
        }
Esempio n. 33
0
        public void Relational_Store_Deletes_record_with_string_id()
        {
            var BuildingStore = new SqliteRelationalStore <Building>(_db);
            var newBuilding   = new Building {
                BIN = "OR300-01", Identifier = "Building D", PropertyId = 1
            };

            BuildingStore.Add(newBuilding);

            // Load from back-end:
            var buildings = BuildingStore.TryLoadData();
            int qtyAdded  = buildings.Count;

            // Delete:
            var foundBuilding = buildings.FirstOrDefault();

            BuildingStore.Delete(foundBuilding);

            int remaining = BuildingStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == 1 && remaining == 0);
        }
Esempio n. 34
0
        public void Relational_Store_Inserts_record_with_string_id()
        {
            var theBin        = "OR13-22";
            var BuildingStore = new SqliteRelationalStore <Building>(_db);
            var newBuilding   = new Building {
                BIN = "OR13-22", Identifier = "Building A", PropertyId = 1
            };

            BuildingStore.Add(newBuilding);

            var foundBuilding = BuildingStore.TryLoadData().FirstOrDefault();

            Assert.IsTrue(foundBuilding != null && foundBuilding.BIN == theBin);
        }
        public void Relational_Store_Deletes_all_records_with_serial_id()
        {
            var PropertyStore = new SqliteRelationalStore <Property>(_db);
            var myBatch       = new List <Property>();
            int qtyToAdd      = 10;

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

            // Re-load from back-end:
            var companies = PropertyStore.TryLoadData();
            int qtyAdded  = companies.Count;

            // Delete:
            PropertyStore.DeleteAll();
            int remaining = PropertyStore.TryLoadData().Count;

            Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
        }
Esempio n. 36
0
        public void Relational_Store_Updates_record_with_pg_names()
        {
            var UnitStore = new SqliteRelationalStore <Unit>(_db);
            var newUnit   = new Unit {
                BIN = "OR05-01", UnitNo = "C-101"
            };

            UnitStore.Add(newUnit);

            // Now go fetch the record again and update:
            string newName   = "Updated-401";
            var    foundUnit = UnitStore.TryLoadData().FirstOrDefault();

            foundUnit.UnitNo = newName;
            UnitStore.Update(foundUnit);
            Assert.IsTrue(foundUnit != null && foundUnit.UnitNo == newName);
        }
        public void Relational_Store_Inserts_range_of_records_with_name_attributes()
        {
            var WorkOrderStore = new SqliteRelationalStore <WorkOrder>(_db);
            var myBatch        = new List <WorkOrder>();
            int qtyToAdd       = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                var newWorkOrder = new WorkOrder {
                    Description = "Replace Lightbulbs " + i
                };
                myBatch.Add(newWorkOrder);
            }
            WorkOrderStore.Add(myBatch);
            var workOrders = WorkOrderStore.TryLoadData();

            Assert.IsTrue(workOrders.Count == qtyToAdd);
        }
        public void Relational_Store_Inserts_range_of_records_with_serial_id()
        {
            var propertyStore = new SqliteRelationalStore <Property>(_db);
            var myBatch       = new List <Property>();
            int qtyToAdd      = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                var newProperty = new Property {
                    Name = "New Apartment " + i, Address = "Some Street in a Lonely Town"
                };
                myBatch.Add(newProperty);
            }
            propertyStore.Add(myBatch);
            var companies = propertyStore.TryLoadData();

            Assert.IsTrue(companies.Count == qtyToAdd);
        }
Esempio n. 39
0
        public void Relational_Store_Inserts_range_of_records_with_string_id()
        {
            var BuildingStore = new SqliteRelationalStore <Building>(_db);
            var myBatch       = new List <Building>();
            int qtyToAdd      = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                var newBuilding = new Building {
                    BIN = "OR13-" + i, Identifier = "Building " + i, PropertyId = i
                };
                myBatch.Add(newBuilding);
            }
            BuildingStore.Add(myBatch);
            var buildings = BuildingStore.TryLoadData();

            Assert.IsTrue(buildings.Count == qtyToAdd);
        }
Esempio n. 40
0
        public void Relational_Store_Inserts_range_of_records_with_pg_names()
        {
            var UnitStore = new SqliteRelationalStore <Unit>(_db);
            var myBatch   = new List <Unit>();
            int qtyToAdd  = 10;

            for (int i = 1; i <= qtyToAdd; i++)
            {
                var newUnit = new Unit {
                    BIN = "OR04-" + i, UnitNo = "B-10" + i
                };
                myBatch.Add(newUnit);
            }
            UnitStore.Add(myBatch);
            var companies = UnitStore.TryLoadData();

            Assert.IsTrue(companies.Count == qtyToAdd);
        }
    public void Relational_Store_Updates_range_of_records_with_pg_names() {
      var UnitStore = new SqliteRelationalStore<Unit>(_db);
      var myBatch = new List<Unit>();
      int qtyToAdd = 10;
      for (int i = 1; i <= qtyToAdd; i++) {
        var newUnit = new Unit { BIN = "OR06-" + i, UnitNo = "D-10" + i };
        myBatch.Add(newUnit);
      }
      UnitStore.Add(myBatch);

      // Re-load, and update:
      var companies = UnitStore.TryLoadData();
      for (int i = 0; i < qtyToAdd; i++) {
        companies.ElementAt(i).UnitNo = "Updated-50" + i;
      }
      UnitStore.Update(companies);

      // Reload, and check updated names:
      companies = UnitStore.TryLoadData().Where(c => c.UnitNo.Contains("Updated")).ToList();
      Assert.IsTrue(companies.Count == qtyToAdd);
    }
    public void Relational_Store_Deletes_range_of_records_with_pg_names() {
      var UnitStore = new SqliteRelationalStore<Unit>(_db);
      var myBatch = new List<Unit>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        var newUnit = new Unit { BIN = "OR08-" + i, UnitNo = "F-10" + i };
        myBatch.Add(newUnit);
      }
      UnitStore.Add(myBatch);

      // Re-load from back-end:
      var companies = UnitStore.TryLoadData();
      int qtyAdded = companies.Count;

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

      // Delete:
      UnitStore.Delete(deleteThese);
      int remaining = UnitStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
    }
    public void Relational_Store_Deletes_all_records_with_pg_names() {
      var UnitStore = new SqliteRelationalStore<Unit>(_db);
      var myBatch = new List<Unit>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        var newUnit = new Unit { BIN = "OR09-" + i, UnitNo = "G-10" + i };
        myBatch.Add(newUnit);
      }
      UnitStore.Add(myBatch);

      // Re-load from back-end:
      var companies = UnitStore.TryLoadData();
      int qtyAdded = companies.Count;

      // Delete:
      UnitStore.DeleteAll();
      int remaining = UnitStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
    }
    public void Relational_Store_Updates_range_of_records_with_name_attributes() {
      var WorkOrderStore = new SqliteRelationalStore<WorkOrder>(_db);
      var myBatch = new List<WorkOrder>();
      int qtyToAdd = 10;
      for (int i = 1; i <= qtyToAdd; i++) {
        var newWorkOrder = new WorkOrder { Description = "Caulk Tub " + i };
        myBatch.Add(newWorkOrder);
      }
      WorkOrderStore.Add(myBatch);

      // Re-load, and update:
      var workOrders = WorkOrderStore.TryLoadData();
      for (int i = 0; i < qtyToAdd; i++) {
        workOrders.ElementAt(i).Description = "Updated Tubs" + i;
      }
      WorkOrderStore.Update(workOrders);

      // Reload, and check updated names:
      workOrders = WorkOrderStore.TryLoadData().Where(c => c.Description.Contains("Updated")).ToList();
      Assert.IsTrue(workOrders.Count == qtyToAdd);
    }
    public void Relational_Store_Deletes_record_with_name_attributes() {
      var WorkOrderStore = new SqliteRelationalStore<WorkOrder>(_db);
      var newWorkOrder = new WorkOrder { Description = "Eradicate bed bugs" };
      WorkOrderStore.Add(newWorkOrder);

      // Load from back-end:
      var workOrders = WorkOrderStore.TryLoadData();
      int qtyAdded = workOrders.Count;

      // Delete:
      var foundWorkOrder = workOrders.FirstOrDefault();
      WorkOrderStore.Delete(foundWorkOrder);

      int remaining = WorkOrderStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == 1 && remaining == 0);
    }
    public void Relational_Store_Deletes_range_of_records_with_string_id() {
      var BuildingStore = new SqliteRelationalStore<Building>(_db);
      var myBatch = new List<Building>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        var newBuilding = new Building { BIN = "OR400-" + i, Identifier = "Building " + i, PropertyId = i };
        myBatch.Add(newBuilding);
      }
      BuildingStore.Add(myBatch);

      // Re-load from back-end:
      var buildings = BuildingStore.TryLoadData();
      int qtyAdded = buildings.Count;

      // Select 5 for deletion:
      int qtyToDelete = 5;
      var deleteThese = new List<Building>();
      for (int i = 0; i < qtyToDelete; i++) {
        deleteThese.Add(buildings.ElementAt(i));
      }

      // Delete:
      BuildingStore.Delete(deleteThese);
      int remaining = BuildingStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
    }
    public void Relational_Store_Deletes_record_with_pg_names() {
      var UnitStore = new SqliteRelationalStore<Unit>(_db);
      var newUnit = new Unit { BIN = "OR07-01", UnitNo = "E-101" };
      UnitStore.Add(newUnit);

      // Load from back-end:
      var companies = UnitStore.TryLoadData();
      int qtyAdded = companies.Count;

      // Delete:
      var foundUnit = companies.FirstOrDefault();
      UnitStore.Delete(foundUnit);

      int remaining = UnitStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == 1 && remaining == 0);
    }
    public void Relational_Store_Deletes_all_records_with_name_attributes() {
      var WorkOrderStore = new SqliteRelationalStore<WorkOrder>(_db);
      var myBatch = new List<WorkOrder>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        var newWorkOrder = new WorkOrder { Description = "Kill Roaches dead " + i };
        myBatch.Add(newWorkOrder);
      }
      WorkOrderStore.Add(myBatch);

      // Re-load from back-end:
      var workOrders = WorkOrderStore.TryLoadData();
      int qtyAdded = workOrders.Count;

      // Delete:
      WorkOrderStore.DeleteAll();
      int remaining = WorkOrderStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
    }
Esempio n. 49
0
    public void Run() {
      Console.WriteLine("SQLite Relational Demo - TEST DATA");
      Console.WriteLine("====================================");
      Console.WriteLine("Initialize Test Db");

      var sw = new Stopwatch();

      sw.Start();
      _testDb = new SqliteChinookDb("BiggyTest", dropCreateTables: true);
      sw.Stop();
      Console.WriteLine("Initialized and reset SQLite database in {0} MS", sw.ElapsedMilliseconds);

      Console.WriteLine("Write some test data...");
      var sampleArtists = SampleData.GetSampleArtists(qty: 1000);
      var sampleAlbums = SampleData.GetSampleAlbums(qtyPerArtist: 3);
      var sampleTracks = SampleData.GetSampleTracks(qtyPerAlbum: 8);

      sw.Reset();
      sw.Start();
      _testDb.Artists.Add(sampleArtists);
      sw.Stop();
      Console.WriteLine("Wrote {0} artist records in {1} ms", sampleArtists.Count, sw.ElapsedMilliseconds);

      sw.Reset();
      sw.Start();
      _testDb.Albums.Add(sampleAlbums);
      sw.Stop();
      Console.WriteLine("Wrote {0} album records in {1} ms", sampleAlbums.Count, sw.ElapsedMilliseconds);

      sw.Reset();
      sw.Start();
      _testDb.Tracks.Add(sampleTracks);
      sw.Stop();
      Console.WriteLine("Wrote {0} track records in {1} ms", sampleTracks.Count, sw.ElapsedMilliseconds);

      Console.WriteLine("");
      Console.WriteLine("Re-Initialize Db and read all that data from back-end...");
      Console.WriteLine("");

      sw.Reset();
      sw.Start();
      _testDb.LoadData();
      sw.Stop();
      Console.WriteLine("Read all data from store in {0} ms", sw.ElapsedMilliseconds);
      Console.WriteLine("{0} Artists", _testDb.Artists.Count);
      Console.WriteLine("{0} Albums", _testDb.Albums.Count);
      Console.WriteLine("{0} Tracks", _testDb.Tracks.Count);

      Console.WriteLine("Update a whole bunch of artist records...");
      var updateArtists = _testDb.Artists.ToList();
      foreach (var artist in updateArtists) {
        artist.Name = "Updated Artist " + artist.ArtistId;
      }
      sw.Reset();
      sw.Start();
      _testDb.Artists.Update(updateArtists);
      sw.Stop();
      Console.WriteLine("Updated {0} artist records in {1} ms", updateArtists.Count, sw.ElapsedMilliseconds);

      Console.WriteLine("");
      Console.WriteLine("SQLite Relational Demo - CHINOOK DATA");
      Console.WriteLine("=======================================");

      Console.WriteLine("Now let's use some actual data from Chinook Db...");

      sw.Reset();
      sw.Start();
      _chinookDb = new SqliteChinookDb("Chinook");
      var _tempDb = new SqliteDbCore("Chinook");
      var _tempStore = new SqliteRelationalStore<Artist>(_tempDb);
      var tempArtists = _tempStore.TryLoadData();
      sw.Stop();
      Console.WriteLine("Initialized Chinook data in {0} ms - loaded:", sw.ElapsedMilliseconds);
      Console.WriteLine("{0} Artists", _chinookDb.Artists.Count);
      Console.WriteLine("{0} Albums", _chinookDb.Albums.Count);
      Console.WriteLine("{0} Tracks", _chinookDb.Tracks.Count);

      Console.WriteLine("");
      Console.WriteLine("Some fancy Querying - CHINOOK DATA");
      Console.WriteLine("==================================");

      Console.WriteLine("");
      Console.WriteLine("Find all albums by a particular Artist using LINQ join");
      string artistToFind = "Metallica";

      sw.Reset();
      sw.Start();
      var artistAlbums = (from a in _chinookDb.Albums
                          join ar in _chinookDb.Artists on a.ArtistId equals ar.ArtistId
                          where ar.Name == artistToFind
                          select a).ToList();
      // We use .ToList() because the objects aren't enumerated until used - we want a rough perf measurement to fetch the objects.
      sw.Stop();

      Console.WriteLine("\tArtist: {0}:", artistToFind);
      foreach (var album in artistAlbums) {
        Console.WriteLine("\t  -{0}", album.Title);
      }
      Console.WriteLine("Found {0} albums for {1} out of {2} in {3} ms", artistAlbums.Count(), artistToFind, _chinookDb.Albums.Count, sw.ElapsedMilliseconds);

      Console.WriteLine("");
      Console.WriteLine("Find all tracks by a particular Artist using triple LINQ join");
      artistToFind = "AC/DC";
      sw.Reset();
      sw.Start();
      var artistTracks = (from t in _chinookDb.Tracks
                          join al in _chinookDb.Albums on t.AlbumId equals al.AlbumId
                          join ar in _chinookDb.Artists on al.ArtistId equals ar.ArtistId
                          where ar.Name == artistToFind
                          select t).ToList();

      Console.WriteLine("\tArtist: {0}:", artistToFind);
      foreach (var track in artistTracks) {
        Console.WriteLine("\t  -{0}", track.Name);
      }
      Console.WriteLine("Found {0} tracks for {1} from {2} albums among {3} total tracks in {4} ms", artistTracks.Count(), artistToFind, _chinookDb.Albums.Count, _chinookDb.Tracks.Count, sw.ElapsedMilliseconds);
    }
Esempio n. 50
0
    public void Run() {

      Console.WriteLine("Postgres Perf");
      Console.WriteLine("=============");


      PgDropCreate.DropCreateAll(_pgDb);
      var pgStore = new PgRelationalStore<Artist>(_pgDb);
      var pgMemoryArtists = new List<Artist>();

      var pgNewArtists = new List<Artist>();
      for (int i = 1; i <= 10000; i++) {
        pgNewArtists.Add(new Artist { Name = "New Artist " + i });
      }

      var sw = new System.Diagnostics.Stopwatch();
      sw.Start();
      pgStore.Add(pgNewArtists);
      sw.Stop();
      Console.WriteLine("Added {0} new Artists in {1} ms", pgNewArtists.Count, sw.ElapsedMilliseconds);

      sw.Reset();
      sw.Start();
      var pgAllArtists = pgStore.TryLoadData();
      sw.Stop();
      Console.WriteLine("Read {0} Artists from DB in {1} ms", pgAllArtists.Count, sw.ElapsedMilliseconds);

      foreach (var artist in pgAllArtists) {
        artist.Name = "UPDATED";
      }

      sw.Reset();
      sw.Start();
      pgStore.Update(pgAllArtists);
      sw.Stop();
      Console.WriteLine("Updated {0} new Artists in {1} ms", pgAllArtists.Count, sw.ElapsedMilliseconds);

      sw.Reset();
      sw.Start();
      int pgHowMany = pgStore.Delete(pgAllArtists);
      sw.Stop();
      Console.WriteLine("Delted {0} new Artists in {1} ms", pgHowMany, sw.ElapsedMilliseconds);

      Console.WriteLine("SQLite Perf");
      Console.WriteLine("===========");

      sqliteDropCreate.DropCreateAll(_sqlitedb);
      var sqliteStore = new SqliteRelationalStore<Artist>(_sqlitedb);
      var sqliteMemoryArtists = new List<Artist>();

      var sqliteNewArtists = new List<Artist>();
      for (int i = 1; i <= 10000; i++) {
        sqliteNewArtists.Add(new Artist { Name = "New Artist " + i });
      }

      sw.Reset();
      sw.Start();
      sqliteStore.Add(sqliteNewArtists);
      sw.Stop();
      Console.WriteLine("Added {0} new Artists in {1} ms", sqliteNewArtists.Count, sw.ElapsedMilliseconds);

      sw.Reset();
      sw.Start();
      var sqliteAllArtists = sqliteStore.TryLoadData();
      sw.Stop();
      Console.WriteLine("Read {0} Artists from DB in {1} ms", sqliteAllArtists.Count, sw.ElapsedMilliseconds);

      foreach (var artist in sqliteAllArtists) {
        artist.Name = "UPDATED";
      }

      sw.Reset();
      sw.Start();
      sqliteStore.Update(sqliteAllArtists);
      sw.Stop();
      Console.WriteLine("Updated {0} new Artists in {1} ms", sqliteAllArtists.Count, sw.ElapsedMilliseconds);

      sw.Reset();
      sw.Start();
      int sqliteHowMany = sqliteStore.Delete(sqliteAllArtists);
      sw.Stop();
      Console.WriteLine("Delted {0} new Artists in {1} ms", sqliteHowMany, sw.ElapsedMilliseconds);
    }
    public void Relational_Store_Deletes_range_of_records_with_name_attributes() {
      var WorkOrderStore = new SqliteRelationalStore<WorkOrder>(_db);
      var myBatch = new List<WorkOrder>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        var newWorkOrder = new WorkOrder { Description = "Kill mice dead " + i };
        myBatch.Add(newWorkOrder);
      }
      WorkOrderStore.Add(myBatch);

      // Re-load from back-end:
      var workOrders = WorkOrderStore.TryLoadData();
      int qtyAdded = workOrders.Count;

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

      // Delete:
      WorkOrderStore.Delete(deleteThese);
      int remaining = WorkOrderStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
    }
    public void Relational_Store_Updates_range_of_records_with_string_id() {
      var BuildingStore = new SqliteRelationalStore<Building>(_db);
      var myBatch = new List<Building>();
      int qtyToAdd = 10;
      for (int i = 1; i <= qtyToAdd; i++) {
        var newBuilding = new Building { BIN = "OR13-" + i, Identifier = "Building " + i, PropertyId = i };
        myBatch.Add(newBuilding);
      }
      BuildingStore.Add(myBatch);

      // Re-load, and update:
      var buildings = BuildingStore.TryLoadData();
      for (int i = 0; i < qtyToAdd; i++) {
        buildings.ElementAt(i).Identifier = "Updated Building " + i;
      }
      BuildingStore.Update(buildings);

      // Reload, and check updated names:
      buildings = BuildingStore.TryLoadData().Where(c => c.Identifier.Contains("Updated")).ToList();
      Assert.IsTrue(buildings.Count == qtyToAdd);
    }
Esempio n. 53
0
        public void Run()
        {
            Console.WriteLine("SQLite Relational Demo - TEST DATA");
            Console.WriteLine("====================================");
            Console.WriteLine("Initialize Test Db");

            var sw = new Stopwatch();

            sw.Start();
            _testDb = new SqliteChinookDb("BiggyTest", dropCreateTables: true);
            sw.Stop();
            Console.WriteLine("Initialized and reset SQLite database in {0} MS", sw.ElapsedMilliseconds);

            Console.WriteLine("Write some test data...");
            var sampleArtists = SampleData.GetSampleArtists(qty: 1000);
            var sampleAlbums  = SampleData.GetSampleAlbums(qtyPerArtist: 3);
            var sampleTracks  = SampleData.GetSampleTracks(qtyPerAlbum: 8);

            sw.Reset();
            sw.Start();
            _testDb.Artists.Add(sampleArtists);
            sw.Stop();
            Console.WriteLine("Wrote {0} artist records in {1} ms", sampleArtists.Count, sw.ElapsedMilliseconds);

            sw.Reset();
            sw.Start();
            _testDb.Albums.Add(sampleAlbums);
            sw.Stop();
            Console.WriteLine("Wrote {0} album records in {1} ms", sampleAlbums.Count, sw.ElapsedMilliseconds);

            sw.Reset();
            sw.Start();
            _testDb.Tracks.Add(sampleTracks);
            sw.Stop();
            Console.WriteLine("Wrote {0} track records in {1} ms", sampleTracks.Count, sw.ElapsedMilliseconds);

            Console.WriteLine("");
            Console.WriteLine("Re-Initialize Db and read all that data from back-end...");
            Console.WriteLine("");

            sw.Reset();
            sw.Start();
            _testDb.LoadData();
            sw.Stop();
            Console.WriteLine("Read all data from store in {0} ms", sw.ElapsedMilliseconds);
            Console.WriteLine("{0} Artists", _testDb.Artists.Count);
            Console.WriteLine("{0} Albums", _testDb.Albums.Count);
            Console.WriteLine("{0} Tracks", _testDb.Tracks.Count);

            Console.WriteLine("Update a whole bunch of artist records...");
            var updateArtists = _testDb.Artists.ToList();

            foreach (var artist in updateArtists)
            {
                artist.Name = "Updated Artist " + artist.ArtistId;
            }
            sw.Reset();
            sw.Start();
            _testDb.Artists.Update(updateArtists);
            sw.Stop();
            Console.WriteLine("Updated {0} artist records in {1} ms", updateArtists.Count, sw.ElapsedMilliseconds);

            Console.WriteLine("");
            Console.WriteLine("SQLite Relational Demo - CHINOOK DATA");
            Console.WriteLine("=======================================");

            Console.WriteLine("Now let's use some actual data from Chinook Db...");

            sw.Reset();
            sw.Start();
            _chinookDb = new SqliteChinookDb("Chinook");
            var _tempDb     = new SqliteDbCore("Chinook");
            var _tempStore  = new SqliteRelationalStore <Artist>(_tempDb);
            var tempArtists = _tempStore.TryLoadData();

            sw.Stop();
            Console.WriteLine("Initialized Chinook data in {0} ms - loaded:", sw.ElapsedMilliseconds);
            Console.WriteLine("{0} Artists", _chinookDb.Artists.Count);
            Console.WriteLine("{0} Albums", _chinookDb.Albums.Count);
            Console.WriteLine("{0} Tracks", _chinookDb.Tracks.Count);

            Console.WriteLine("");
            Console.WriteLine("Some fancy Querying - CHINOOK DATA");
            Console.WriteLine("==================================");

            Console.WriteLine("");
            Console.WriteLine("Find all albums by a particular Artist using LINQ join");
            string artistToFind = "Metallica";

            sw.Reset();
            sw.Start();
            var artistAlbums = (from a in _chinookDb.Albums
                                join ar in _chinookDb.Artists on a.ArtistId equals ar.ArtistId
                                where ar.Name == artistToFind
                                select a).ToList();

            // We use .ToList() because the objects aren't enumerated until used - we want a rough perf measurement to fetch the objects.
            sw.Stop();

            Console.WriteLine("\tArtist: {0}:", artistToFind);
            foreach (var album in artistAlbums)
            {
                Console.WriteLine("\t  -{0}", album.Title);
            }
            Console.WriteLine("Found {0} albums for {1} out of {2} in {3} ms", artistAlbums.Count(), artistToFind, _chinookDb.Albums.Count, sw.ElapsedMilliseconds);

            Console.WriteLine("");
            Console.WriteLine("Find all tracks by a particular Artist using triple LINQ join");
            artistToFind = "AC/DC";
            sw.Reset();
            sw.Start();
            var artistTracks = (from t in _chinookDb.Tracks
                                join al in _chinookDb.Albums on t.AlbumId equals al.AlbumId
                                join ar in _chinookDb.Artists on al.ArtistId equals ar.ArtistId
                                where ar.Name == artistToFind
                                select t).ToList();

            Console.WriteLine("\tArtist: {0}:", artistToFind);
            foreach (var track in artistTracks)
            {
                Console.WriteLine("\t  -{0}", track.Name);
            }
            Console.WriteLine("Found {0} tracks for {1} from {2} albums among {3} total tracks in {4} ms", artistTracks.Count(), artistToFind, _chinookDb.Albums.Count, _chinookDb.Tracks.Count, sw.ElapsedMilliseconds);
        }
    public void Relational_Store_Deletes_record_with_string_id() {
      var BuildingStore = new SqliteRelationalStore<Building>(_db);
      var newBuilding = new Building { BIN = "OR300-01", Identifier = "Building D", PropertyId = 1 };
      BuildingStore.Add(newBuilding);

      // Load from back-end:
      var buildings = BuildingStore.TryLoadData();
      int qtyAdded = buildings.Count;

      // Delete:
      var foundBuilding = buildings.FirstOrDefault();
      BuildingStore.Delete(foundBuilding);

      int remaining = BuildingStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == 1 && remaining == 0);
    }
    public void Relational_Store_Updates_range_of_records_with_serial_id() {
      var PropertyStore = new SqliteRelationalStore<Property>(_db);
      var myBatch = new List<Property>();
      int qtyToAdd = 10;
      for (int i = 1; i <= qtyToAdd; i++) {
        myBatch.Add(new Property { Name = "John's Luxury Townhomes" + i, Address = i + " Property Parkway, Portland, OR 97204" });
      }
      PropertyStore.Add(myBatch);

      // Re-load, and update:
      var companies = PropertyStore.TryLoadData();
      for (int i = 0; i < qtyToAdd; i++) {
        companies.ElementAt(i).Name = "John's Low-Rent Brick Homes " + i;
      }
      PropertyStore.Update(companies);

      // Reload, and check updated names:
      companies = PropertyStore.TryLoadData().Where(c => c.Name.Contains("Low-Rent")).ToList();
      Assert.IsTrue(companies.Count == qtyToAdd);
    }
Esempio n. 56
0
        public void Run()
        {
            Console.WriteLine("Postgres Perf");
            Console.WriteLine("=============");


            PgDropCreate.DropCreateAll(_pgDb);
            var pgStore         = new PgRelationalStore <Artist>(_pgDb);
            var pgMemoryArtists = new List <Artist>();

            var pgNewArtists = new List <Artist>();

            for (int i = 1; i <= 10000; i++)
            {
                pgNewArtists.Add(new Artist {
                    Name = "New Artist " + i
                });
            }

            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();
            pgStore.Add(pgNewArtists);
            sw.Stop();
            Console.WriteLine("Added {0} new Artists in {1} ms", pgNewArtists.Count, sw.ElapsedMilliseconds);

            sw.Reset();
            sw.Start();
            var pgAllArtists = pgStore.TryLoadData();

            sw.Stop();
            Console.WriteLine("Read {0} Artists from DB in {1} ms", pgAllArtists.Count, sw.ElapsedMilliseconds);

            foreach (var artist in pgAllArtists)
            {
                artist.Name = "UPDATED";
            }

            sw.Reset();
            sw.Start();
            pgStore.Update(pgAllArtists);
            sw.Stop();
            Console.WriteLine("Updated {0} new Artists in {1} ms", pgAllArtists.Count, sw.ElapsedMilliseconds);

            sw.Reset();
            sw.Start();
            int pgHowMany = pgStore.Delete(pgAllArtists);

            sw.Stop();
            Console.WriteLine("Delted {0} new Artists in {1} ms", pgHowMany, sw.ElapsedMilliseconds);

            Console.WriteLine("SQLite Perf");
            Console.WriteLine("===========");

            sqliteDropCreate.DropCreateAll(_sqlitedb);
            var sqliteStore         = new SqliteRelationalStore <Artist>(_sqlitedb);
            var sqliteMemoryArtists = new List <Artist>();

            var sqliteNewArtists = new List <Artist>();

            for (int i = 1; i <= 10000; i++)
            {
                sqliteNewArtists.Add(new Artist {
                    Name = "New Artist " + i
                });
            }

            sw.Reset();
            sw.Start();
            sqliteStore.Add(sqliteNewArtists);
            sw.Stop();
            Console.WriteLine("Added {0} new Artists in {1} ms", sqliteNewArtists.Count, sw.ElapsedMilliseconds);

            sw.Reset();
            sw.Start();
            var sqliteAllArtists = sqliteStore.TryLoadData();

            sw.Stop();
            Console.WriteLine("Read {0} Artists from DB in {1} ms", sqliteAllArtists.Count, sw.ElapsedMilliseconds);

            foreach (var artist in sqliteAllArtists)
            {
                artist.Name = "UPDATED";
            }

            sw.Reset();
            sw.Start();
            sqliteStore.Update(sqliteAllArtists);
            sw.Stop();
            Console.WriteLine("Updated {0} new Artists in {1} ms", sqliteAllArtists.Count, sw.ElapsedMilliseconds);

            sw.Reset();
            sw.Start();
            int sqliteHowMany = sqliteStore.Delete(sqliteAllArtists);

            sw.Stop();
            Console.WriteLine("Delted {0} new Artists in {1} ms", sqliteHowMany, sw.ElapsedMilliseconds);
        }
    public void Relational_Store_Deletes_range_of_records_with_serial_id() {
      var PropertyStore = new SqliteRelationalStore<Property>(_db);
      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" });
      }
      PropertyStore.Add(myBatch);

      // Re-load from back-end:
      var companies = PropertyStore.TryLoadData();
      int qtyAdded = companies.Count;

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

      // Delete:
      PropertyStore.Delete(deleteThese);
      int remaining = PropertyStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == qtyAdded - qtyToDelete);
    }
    public void Relational_Store_Deletes_all_records_with_string_id() {
      var BuildingStore = new SqliteRelationalStore<Building>(_db);
      var myBatch = new List<Building>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        var newBuilding = new Building { BIN = "OR500-" + i, Identifier = "Building " + i, PropertyId = i };
        myBatch.Add(newBuilding);
      }
      BuildingStore.Add(myBatch);

      // Re-load from back-end:
      var buildings = BuildingStore.TryLoadData();
      int qtyAdded = buildings.Count;

      // Delete:
      BuildingStore.DeleteAll();
      int remaining = BuildingStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
    }
    public void Relational_Store_Deletes_record_with_serial_id() {
      var PropertyStore = new SqliteRelationalStore<Property>(_db);
      var newProperty = new Property { Name = "John's High-End Apartments", Address = "16 Property Parkway, Portland, OR 97204" };
      PropertyStore.Add(newProperty);

      // Load from back-end:
      var companies = PropertyStore.TryLoadData();
      int qtyAdded = companies.Count;

      // Delete:
      var foundProperty = companies.FirstOrDefault();
      PropertyStore.Delete(foundProperty);

      int remaining = PropertyStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == 1 && remaining == 0);
    }
    public void Relational_Store_Deletes_all_records_with_serial_id() {
      var PropertyStore = new SqliteRelationalStore<Property>(_db);
      var myBatch = new List<Property>();
      int qtyToAdd = 10;
      for (int i = 0; i < qtyToAdd; i++) {
        myBatch.Add(new Property { Name = "Park Place" + i, Address = i + " Property Parkway, Portland, OR 97204" });
      }
      PropertyStore.Add(myBatch);

      // Re-load from back-end:
      var companies = PropertyStore.TryLoadData();
      int qtyAdded = companies.Count;

      // Delete:
      PropertyStore.DeleteAll();
      int remaining = PropertyStore.TryLoadData().Count;
      Assert.IsTrue(qtyAdded == qtyToAdd && remaining == 0);
    }