Creating Seed Data - Updated

Monday, September 18, 2006 9:31:38 PM (Central Standard Time, UTC-06:00)

I did another update to my SeedData class, it now supports the creation of:

  • Job Titles
  • Addresses
  • States
  • Zip Codes
  • County

The city, states and zip codes all match appropriately, in other words if you request a random zip for example, it will return the zip with the related City, State and county.  The data is older (from the 1990 census) but it works great for generating real looking dummy data. 

The following code shows how to use the class

//Load external Seed Data files that aren't automatically loaded (check src to see which are)

SeedData.LoadSeedData("Titles", string.Format(@"{0}\SeedData_JobTitles.txt", Application.StartupPath), 0);

SeedData.LoadSeedData("Address", string.Format(@"{0}\SeedData_Addresses.txt", Application.StartupPath), 0);

 

PersonTableGateway gw = new PersonTableGateway();

 

using(new PerformanceTimer())

{

 

    for (int i = 0; i < 500; i++)

    {

        //create a record using the SeedData class

        Person p = new Person();

        p.FirstName = SeedData.GetFirstName().Trim();

        p.LastName = SeedData.GetLastName().Trim();

        p.NetworkUserID = p.FirstName.Substring(0, 1) + p.LastName;

        p.EMail = p.NetworkUserID.Trim() + "@sysknowlogy.com";

        p.Phone = SeedData.CreatePhone("612");

        p.Title = SeedData.GetRandomSeed("Titles");

        p.TitleDescription = "Description of the title goes here.";

 

        //create a street address

        p.Address1 = SeedData.Number(1000,9999) + " " + SeedData.GetRandomSeed("Address");

 

        ZipCode zip = SeedData.GetZip();

        p.Zip = zip.Zip;

        p.City = zip.City;

        p.State = zip.State;

        p.Branch = zip.City;

 

        gw.CreatePerson(p);

 

    }

}

 

 

 

SeedData1.zip (564.84 KB)