예제 #1
0
 public virtual T Remove(T item)
 {
     if (_biggyStore != null)
     {
         _biggyStore.Remove(item);
         _luceneIndexer.DeleteDocumentFromIndex(item);
     }
     return(item);
 }
예제 #2
0
 public virtual T Remove(T item)
 {
     _items.Remove(item);
     if (_store != null && !this.InMemory)
     {
         _store.Remove(item);
     }
     Fire(ItemRemoved, item: item);
     return(item);
 }
예제 #3
0
파일: Store.cs 프로젝트: superted17/biggy
        public void Removes_Item_From_Store()
        {
            _widgets.Clear();
            _widgets.Add(new Widget {
                SKU = "001", Name = "Test widget 1", Price = 2.00M
            });
            var removeMe = _widgets.Load().FirstOrDefault();

            _widgets.Remove(removeMe);
            var remainingWidgets = _widgets.Load();

            Assert.True(remainingWidgets.Count() == 0);
        }
예제 #4
0
        public void Deletes_Document_With_Composite_PK()
        {
            var newBuilding = new BuildingDocument {
                PropertyId = 1,
                BuildingId = 1,
                Name       = "Building 1"
            };

            buildingDocs.Add(newBuilding);
            // Count after adding new:
            int initialCount = buildingDocs.Load().Count();
            var removed      = buildingDocs.Remove(newBuilding);
            // Count after removing and reloading:
            int finalCount = buildingDocs.Load().Count();

            Assert.True(finalCount < initialCount);
        }
예제 #5
0
        public void Deletes_Document_With_Serial_PK()
        {
            var newCustomer = new ClientDocument {
                Email     = "*****@*****.**",
                FirstName = "Rob",
                LastName  = "Conery"
            };

            clientDocs.Add(newCustomer);
            // Count after adding new:
            int initialCount = clientDocs.Load().Count();
            var removed      = clientDocs.Remove(newCustomer);
            // Count after removing and reloading:
            int finalCount = clientDocs.Load().Count();

            Assert.True(finalCount < initialCount);
        }
예제 #6
0
        public void Deletes_Single_Record_With_Composite_PK()
        {
            var list = new List <Building>();

            for (int i = 1; i <= 10; i++)
            {
                list.Add(new Building {
                    PropertyId = 1, BuildingId = i, Name = "Building " + i
                });
            }
            int initialCount = list.Count;

            _buildingStore.Add(list);

            var deleteMe = _buildingStore.Load().FirstOrDefault(b => b.PropertyId == 1 && b.BuildingId == 3);

            _buildingStore.Remove(deleteMe);

            var fetchBuildings = _buildingStore.Load();

            Assert.True(initialCount == 10 && fetchBuildings.Count() == 9);
        }
예제 #7
0
        public void IUpdateableBiggyStore_Deletes_Many_Records()
        {
            _biggyStore = new SqlCeStore <Client>(_connectionStringName);
            var insertThese = new List <Client>();

            for (int i = 0; i < 10; i++)
            {
                var newClient = new Client()
                {
                    LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**"
                };
                insertThese.Add(newClient);
            }
            _biggyStore.Add(insertThese);
            var newClients = _biggyStore.Load();

            _biggyStore.Remove(newClients);
            newClients = _biggyStore.Load();
            Assert.True(newClients.Count == 0);
        }
예제 #8
0
        void Removing_list_of_documents_no_auto_Pk()
        {
            var startDate = new DateTime(1980, 1, 1);
            var addRange  = new List <MonkeyDocument>();
            int i         = 0;

            while (++i < 30)
            {
                addRange.Add(new MonkeyDocument {
                    Name     = "Monkey" + i.ToString(),
                    Birthday = startDate.AddYears(i)
                });
            }
            monkeyDocs.Add(addRange);

            var monkeys = addRange.Where(m => m.Birthday.Year > 1988 && m.Birthday.Year < 1999).ToList();

            monkeyDocs.Remove(monkeys);

            monkeys = monkeyDocs.Load();
            Assert.False(monkeys.Any(m => m.Birthday.Year > 1988 && m.Birthday.Year < 1999));
        }
예제 #9
0
        public void IUpdateableBiggyStore_Deletes_Record()
        {
            _biggyStore = new SqlCeStore <Client>(_connectionStringName);
            var newClient = new Client()
            {
                LastName = "Atten", FirstName = "John", Email = "*****@*****.**"
            };

            _biggyStore.Add(newClient);

            // Stow the id so we can reload, then update (just to be SURE!!)
            int idToFind = newClient.ClientId;

            newClient = _biggyStore.Load().FirstOrDefault(c => c.ClientId == idToFind);

            var deleteMe = _biggyStore.Load().FirstOrDefault(c => c.ClientId == idToFind);

            _biggyStore.Remove(deleteMe);
            var clients = _biggyStore.Load();

            Assert.True(clients.Count == 0);
        }
예제 #10
0
        void Deletes_Range_of_Documents_With_String_PK()
        {
            int INSERT_QTY = 100;
            var bulkList   = new List <MonkeyDocument>();

            for (int i = 1; i <= INSERT_QTY; i++)
            {
                var newMonkeyDocument = new MonkeyDocument {
                    Name        = "MonkeyDocument " + i,
                    Birthday    = DateTime.Now,
                    Description = "This is Monkey number " + i
                };
                bulkList.Add(newMonkeyDocument);
            }
            monkeyDocs.Add(bulkList);

            var inserted      = monkeyDocs.Load();
            int insertedCount = inserted.Count;

            var deleteUs  = monkeyDocs.Remove(inserted);
            var remaining = monkeyDocs.Load();

            Assert.True(insertedCount > remaining.Count && remaining.Count == 0);
        }
예제 #11
0
        public void IUpdateableBiggyStore_Deletes_Record()
        {
            _biggyStore = new PGStore<Client>(_connectionStringName);
              var newClient = new Client() { LastName = "Atten", FirstName = "John", Email = "*****@*****.**" };
              _biggyStore.Add(newClient);

              // Stow the id so we can reload, then update (just to be SURE!!)
              int idToFind = newClient.ClientId;
              newClient = _biggyStore.Load().FirstOrDefault(c => c.ClientId == idToFind);

              var deleteMe = _biggyStore.Load().FirstOrDefault(c => c.ClientId == idToFind);
              _biggyStore.Remove(deleteMe);
              var clients = _biggyStore.Load();
              Assert.True(clients.Count == 0);
        }
예제 #12
0
        public void IUpdateableBiggyStore_Deletes_Many_Records()
        {
            _biggyStore = new PGStore<Client>(_connectionStringName);
              var insertThese = new List<Client>();

              for (int i = 0; i < 10; i++) {
            var newClient = new Client() { LastName = string.Format("LastName {0}", i), FirstName = "John", Email = "*****@*****.**" };
            insertThese.Add(newClient);
              }
              _biggyStore.Add(insertThese);
              var newClients = _biggyStore.Load();

              _biggyStore.Remove(newClients);
              newClients = _biggyStore.Load();
              Assert.True(newClients.Count == 0);
        }