private void buttonAdd_Click(object sender, EventArgs e) { string Msg; if (!Validate(out Msg)) { MessageBox.Show(Msg); return; } BayWind.Address addr = new BayWind.Address() { Street = textBoxStreet.Text, City = textBoxCity.Text, State = textBoxState.Text, Country = textBoxCountry.Text, ZipCode = textBoxZip.Text, AddressID = (int)AddressStore.GetNextSequence() }; BayWind.Person p = new BayWind.Person() { FirstName = textBoxFirstName.Text, LastName = textBoxLastName.Text, PhoneNumber = textBoxPhone.Text, AddressID = addr.AddressID }; PeopleStore.Add(p.GetKey(), p); AddressStore.Add(addr.AddressID, addr); GoPreviousPage(); DisplayPage(); }
void Populate() { int ZipCodeCtr = 5000; for (int i = 0; i < MaxCount; i++) { int aid = (int)AddressStore.GetNextSequence(); Address addr = new Address() { AddressID = aid, Key = new AddressKey() { Street = string.Format("143{0} LoveLane", aid), City = "Fremont", Country = "USA", State = "California", ZipCode = ZipCodeCtr.ToString() } }; int pid = (int)PeopleStore.GetNextSequence(); Person p = new Person() { PersonID = pid, AddressID = addr.AddressID, Key = new PersonKey() { FirstName = string.Format("Joe{0}", pid), LastName = string.Format("Peter{0}", pid) }, PhoneNumber = "510-555-9999" }; AddressStore.Add(addr.AddressID, addr); PeopleStore.Add(p.PersonID, p); PeopleStoreByName.Add(p.Key, p.PersonID); AddressStoreByAddress.Add(addr.Key, addr.AddressID); if (i % 500 == 0) { ZipCodeCtr++; AddressStore.Flush(); PeopleStore.Flush(); PeopleStoreByName.Flush(); AddressStoreByAddress.Flush(); } } AddressStore.Flush(); PeopleStore.Flush(); PeopleStoreByName.Flush(); AddressStoreByAddress.Flush(); }
void Populate() { int ZipCodeCtr = 5000; CacheRecord[] BatchedRecords = new CacheRecord[BatchCount]; int BatchedIndex = 0; for (int i = 0; i < MaxCount; i++) { int aid = (int)AddressStore.GetNextSequence(); Address addr = new Address() { AddressID = aid, Key = new AddressKey() { Street = string.Format("143{0} LoveLane", aid), City = "Fremont", Country = "USA", State = "California", ZipCode = ZipCodeCtr.ToString() } }; int pid = (int)PeopleStore.GetNextSequence(); Person p = new Person() { PersonID = pid, AddressID = addr.AddressID, Key = new PersonKey() { FirstName = string.Format("Joe{0}", pid), LastName = string.Format("Peter{0}", pid) }, PhoneNumber = "510-555-9999" }; BatchedRecords[BatchedIndex++] = new CacheRecord() { p = p, pKey = p.Key, addr = addr, addrKey = addr.Key }; if (BatchedIndex == BatchCount) { for (int i2 = 0; i2 < BatchedIndex; i2++) { AddressStore.Add(BatchedRecords[i2].addr.AddressID, BatchedRecords[i2].addr); } AddressStore.Flush(); for (int i2 = 0; i2 < BatchedIndex; i2++) { PeopleStore.Add(BatchedRecords[i2].p.PersonID, BatchedRecords[i2].p); } PeopleStore.Flush(); for (int i2 = 0; i2 < BatchedIndex; i2++) { PeopleStoreByName.Add(BatchedRecords[i2].p.Key, BatchedRecords[i2].p.PersonID); } PeopleStoreByName.Flush(); for (int i2 = 0; i2 < BatchedIndex; i2++) { AddressStoreByAddress.Add(BatchedRecords[i2].addr.Key, BatchedRecords[i2].addr.AddressID); } AddressStoreByAddress.Flush(); if (i % 500 == 0) { ZipCodeCtr++; } BatchedIndex = 0; } } if (BatchedIndex > 0) { for (int i2 = 0; i2 < BatchedIndex; i2++) { AddressStore.Add(BatchedRecords[i2].addr.AddressID, BatchedRecords[i2].addr); } AddressStore.Flush(); for (int i2 = 0; i2 < BatchedIndex; i2++) { PeopleStore.Add(BatchedRecords[i2].p.PersonID, BatchedRecords[i2].p); } PeopleStore.Flush(); for (int i2 = 0; i2 < BatchedIndex; i2++) { PeopleStoreByName.Add(BatchedRecords[i2].p.Key, BatchedRecords[i2].p.PersonID); } PeopleStoreByName.Flush(); for (int i2 = 0; i2 < BatchedIndex; i2++) { AddressStoreByAddress.Add(BatchedRecords[i2].addr.Key, BatchedRecords[i2].addr.AddressID); } AddressStoreByAddress.Flush(); } }