Beispiel #1
0
 internal void EditDriversLicense(string driversLicense)
 {
     _logger.Info("Entering EditDriversLicense()");
     DriversLicense.Clear();
     DriversLicense.SendKeys(driversLicense);
     _logger.Info("Exiting EditDriversLicense()");
 }
Beispiel #2
0
        private void FillLabels(Ballot ballet, DriversLicense driversLicense, Social social, Voter voter)
        {
            //Ballet
            FirstNameLable.Text = ballet.FirstName;
            LastNameLable.Text  = ballet.LastName;
            CityLable.Text      = ballet.City;
            ZipLable.Text       = ballet.ZipCode;
            StateLable.Text     = ballet.State;
            SSNLable.Text       = ballet.SSID;
            AddressLable1.Text  = ballet.AddressLine1;
            Address2Lable.Text  = ballet.AddressLine2;
            InputPicture.Image  = voter.Photo;

            //driver
            DLFirstNameLable.Text       = driversLicense.FirstName;
            DLLastNameLable.Text        = driversLicense.LastName;
            DLCityLable.Text            = driversLicense.City;
            DLZipLable.Text             = driversLicense.ZipCode;
            DLStateLable.Text           = driversLicense.State;
            DLGenderLable.Text          = driversLicense.Gender.ToString();
            DriversLicensePicture.Image = driversLicense.Photo;


            //need address line one and two here


            //SSN
            label1.Text             = social.FullName;
            SSIDFirstNameLable.Text = social.FullName;
            SSIDNumberLable.Text    = social.SSN;
        }
Beispiel #3
0
    /// <summary>
    /// Retrieves objects from the <see cref="SerializationInfo"/> store.
    /// </summary>
    /// <returns></returns>
    public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
    {
        DriversLicense license = (DriversLicense)obj;

        license.Number = info.GetString("Number");
        return(license);
    }
Beispiel #4
0
        /*public void InitializeData()
         * {
         *      try
         *      {
         *              // Create a new adapter and give it a query to fetch sales order, contact,
         *              // address, and product information for sales in the year 2002. Point connection
         *              // information to the configuration setting "AdventureWorks".
         *              string connectionString = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=BytejamDatabase;Integrated Security=True";
         *              SqlConnection connection = new SqlConnection( connectionString );
         *
         *              InitializeVoters( connection );
         *              InitializeBallots( connection );
         *              InitializeLicenses( connection );
         *              InitializeSocials( connection );
         *      }
         *      catch ( SqlException ex )
         *      {
         *              Console.WriteLine( "SQL exception occurred: " + ex.Message );
         *      }
         * }
         * private void InitializeVoters( SqlConnection connection )
         * {
         *      string commandText = "select * from Voters";
         *      SqlCommand command = new SqlCommand( commandText, connection );
         *
         *      SqlDataAdapter da = new SqlDataAdapter( command );
         *      da.SelectCommand = command;
         *
         *      voters = new List<Voter>();
         *
         *      DataTable dt = new DataTable();
         *
         *      da.Fill( dt );
         *
         *      SortedDictionary<int, Voter> votersSorted = new SortedDictionary<int, Voter>();
         *
         *      foreach ( DataRow row in dt.Rows )
         *      {
         *              if ( int.TryParse( row.Field<string>( "CID" ), out int rowIndex ) )
         *                      if ( rowIndex > -1 )
         *                              votersSorted.Add( rowIndex, new Voter( row, rowIndex ) );
         *      }
         *
         *      foreach ( Voter voter in votersSorted.Values )
         *              voters.Add( voter );
         * }
         * private void InitializeBallots( SqlConnection connection )
         * {
         *      string commandText = "select * from Ballots";
         *      SqlCommand command = new SqlCommand( commandText, connection );
         *
         *      SqlDataAdapter da = new SqlDataAdapter( command );
         *      da.SelectCommand = command;
         *
         *      ballots = new List<Ballot>();
         *
         *      DataTable dt = new DataTable();
         *
         *      da.Fill( dt );
         *
         *      foreach ( DataRow row in dt.Rows )
         *              ballots.Add( new Ballot( row ) );
         * }
         * private void InitializeLicenses( SqlConnection connection )
         * {
         *      string commandText = "select * from Licenses";
         *      SqlCommand command = new SqlCommand( commandText, connection );
         *
         *      SqlDataAdapter da = new SqlDataAdapter( command );
         *      da.SelectCommand = command;
         *
         *      driversLicenses = new List<DriversLicense>();
         *
         *      DataTable dt = new DataTable();
         *
         *      da.Fill( dt );
         *
         * //help i have know idea what this trash is
         * SortedDictionary<int, DriversLicense> driversLicensesSorted = new SortedDictionary<int, DriversLicense>();
         *
         * foreach (DataRow row in dt.Rows)
         * {
         * if (int.TryParse(row.Field<string>("DID"), out int rowIndex))
         *  if (rowIndex > -1)
         *      driversLicensesSorted.Add(rowIndex, new DriversLicense(row, rowIndex));
         * }
         *
         * foreach (DriversLicense driversLicense in driversLicensesSorted.Values)
         * driversLicenses.Add(driversLicense);
         *
         *//*foreach (DataRow row in dt.Rows)
         *              driversLicenses.Add(new DriversLicense(row));*//*
         * }
         * private void InitializeSocials( SqlConnection connection )
         * {
         *      string commandText = "select * from SocialSecurities";
         *      SqlCommand command = new SqlCommand( commandText, connection );
         *
         *      SqlDataAdapter da = new SqlDataAdapter( command );
         *      da.SelectCommand = command;
         *
         *      socials = new List<Social>();
         *
         *      DataTable dt = new DataTable();
         *
         *      da.Fill( dt );
         *
         *      foreach ( DataRow row in dt.Rows )
         *              socials.Add( new Social( row ) );
         * }*/


        public bool ReFill()
        {
            int index = RandomizationModule.random.Next(22);


            Ballot         ballet         = (Ballot)ballots[index].Clone();
            DriversLicense driversLicense = (DriversLicense)driversLicenses[index].Clone();
            Social         social         = (Social)socials[index].Clone();
            Voter          voter          = (Voter)voters[index].Clone();


            bool isCorrect = true;

            if (isCorrect)
            {
                isCorrect = !ballet.Randomize(index);
            }
            if (isCorrect)
            {
                isCorrect = !social.Randomize(index);
            }
            if (isCorrect)
            {
                isCorrect = !driversLicense.Randomize(index);
            }
            if (isCorrect)
            {
                isCorrect = !voter.Randomize(index);
            }

            FillLabels(ballet, driversLicense, social, voter);

            return(isCorrect);
        }
        public void InsertContactTest()
        {
            var dl = new DriversLicense
                                    {
                                        LicenseNumber = "12345678",
                                        DateOfBirth = DateTime.Today,
                                        Expiry = DateTime.Today
                                    };

            var cc = new CreditCard
                                {
                                    CardNumber = "123123131312",
                                    NameOnCard = "J Bloggs",
                                    ExpiryDate = "02/12",
                                    CreditCardType = CreditCardType.Visa
                                };

            var contact = new Contact
            {
                Name = "Joe Bloggs",
                Email = "*****@*****.**",
                DriversLicense = dl,
                CreditCard = cc,
            };

            contactRepository.InsertContact(contact);
            Assert.IsNotNull(contact.Id);
        }
 public void Map(DriversLicense poco)
 {
     poco.DriverID       = this.DriverID;
     poco.LicenseID      = this.LicenseID;
     poco.IssueDate      = this.IssueDate;
     poco.ExpirationDate = this.ExpirationDate;
     poco.MVRReviewDate  = this.MVRReviewDate;
 }
        public void TestDriversLicenseCtor()
        {
            var testResult = new DriversLicense("A635011103018289", "NY");

            Assert.IsNotNull(testResult);
            Assert.IsNotNull(testResult.IssuingState);
            Assert.IsNotNull(testResult.Value);
            Assert.AreEqual("A635011103018289", testResult.Value);
        }
Beispiel #8
0
        protected Driver()
        {
            Rides = new List <Ride>();

            DriversLicense = new DriversLicense();
            Car            = new Car();
            CompanyDetails = new CompanyDetails();
            SystemInfo     = new SystemInfo();
        }
        public void TestRandomDriversLicense()
        {
            var testResult = DriversLicense.RandomDriversLicense();

            Assert.IsNotNull(testResult);
            Console.WriteLine(testResult);

            testResult = DriversLicense.RandomDriversLicense("NY");
            Assert.IsNotNull(testResult);
            Console.WriteLine(testResult);
        }
        public void GetDriverLicense()
        {
            //Arrange
            DriversLicense driverLicense = new DriversLicense();

            //Assert
            Assert.AreEqual(false, driverLicense.GetDriversLicense(16, 20, false, true));
            Assert.AreEqual(false, driverLicense.GetDriversLicense(16, 50, false, false));
            Assert.AreEqual(true, driverLicense.GetDriversLicense(16, 50, true, true));
            Assert.AreEqual(true, driverLicense.GetDriversLicense(18, 0, true, true));
        }
 public DriverLicenseModel(DriversLicense poco)
     : this()
 {
     this.DriverLicenseID = poco.DriverLicenseID;
     this.DriverID        = poco.DriverID;
     this.LicenseID       = poco.LicenseID;
     this.IssueDate       = poco.IssueDate;
     this.ExpirationDate  = poco.ExpirationDate;
     this.MVRReviewDate   = poco.MVRReviewDate;
     this.IsChanged       = false;
 }
Beispiel #12
0
        public void TestToData()
        {
            var testSubject = new DriversLicense("A635011103018289", "NY");
            var testResult  = testSubject.ToData(KindsOfTextCase.Kabab);

            Assert.IsNotNull(testResult);
            Assert.AreNotEqual(0, testResult.Count);
            foreach (var k in testResult.Keys)
            {
                Console.WriteLine($"{k}: {testResult[k]}");
            }
        }
Beispiel #13
0
        private static void InsertDriverLicense(DSModel db, KeyBinder key, DriverLicenseModel model)
        {
            var poco = new DriversLicense();

            model.Map(poco);
            db.Add(poco);
            key.AddKey(poco, model, model.GetName(p => p.DriverLicenseID));
            db.FlushChanges();

            SaveDriverLicensePermits(db, key, poco, model);
            SaveDriverLicenseReminders(db, key, poco, model);
        }
Beispiel #14
0
        private static void SaveDriverLicensePermits(DSModel db, KeyBinder key, DriversLicense poco, DriverLicenseModel model)
        {
            db.ExecuteNonQuery("DELETE FROM drivers_licenses_permits WHERE DriverLicenseID = @DriverLicenseID;",
                               new MySqlParameter("DriverLicenseID", poco.DriverLicenseID));

            string sql = @"
                INSERT INTO drivers_licenses_permits (DriverLicenseID, PermitID) VALUES (@DriverLicenseID, @PermitID);
                SELECT LAST_INSERT_ID();";

            foreach (var per in model.Permits)
            {
                per.DriverLicenseID       = poco.DriverLicenseID;
                per.DriverLicensePermitID = (uint)db.ExecuteScalar <ulong>(sql,
                                                                           new MySqlParameter("DriverLicenseID", per.DriverLicenseID),
                                                                           new MySqlParameter("PermitID", per.PermitID));
            }
        }
Beispiel #15
0
        private static void SaveDriverLicenseReminders(DSModel db, KeyBinder key, DriversLicense poco, DriverLicenseModel model)
        {
            db.ExecuteNonQuery("delete from drivers_licenses_reminders where DriverLicenseID = @DriverLicenseID;",
                               new MySqlParameter("DriverLicenseID", poco.DriverLicenseID));

            string sql = @"
                INSERT INTO drivers_licenses_reminders 
                  (DriverLicenseID, ReminderID, ReminderType, ShouldRemind) 
                  VALUES 
                  (@DriverLicenseID, @ReminderID, @ReminderType, @ShouldRemind);
                SELECT LAST_INSERT_ID();";

            foreach (var rem in model.Reminders)
            {
                rem.DriverLicenseID         = poco.DriverLicenseID;
                rem.DriverLicenseReminderID = (uint)db.ExecuteScalar <ulong>(sql,
                                                                             new MySqlParameter("DriverLicenseID", rem.DriverLicenseID),
                                                                             new MySqlParameter("ReminderID", rem.ReminderID),
                                                                             new MySqlParameter("ReminderType", rem.ReminderType),
                                                                             new MySqlParameter("ShouldRemind", rem.ShouldRemind));
            }
        }
Beispiel #16
0
        protected void AssertLicense(DriversLicense expected, IdentificationCard actualId)
        {
            Assert.IsNotNull(expected);
            Assert.IsNotNull(actualId);
            Assert.IsInstanceOfType(actualId, typeof(DriversLicense));

            var actual = (DriversLicense)actualId;

            Assert.IsNotNull(actual.Jurisdiction);

            Assert.AreEqual(expected.Jurisdiction.VehicleClass, actual.Jurisdiction.VehicleClass, nameof(actual.Jurisdiction.VehicleClass));
            Assert.AreEqual(expected.Jurisdiction.RestrictionCodes, actual.Jurisdiction.RestrictionCodes, nameof(actual.Jurisdiction.RestrictionCodes));
            Assert.AreEqual(expected.Jurisdiction.EndorsementCodes, actual.Jurisdiction.EndorsementCodes, nameof(actual.Jurisdiction.EndorsementCodes));
            Assert.AreEqual(expected.Jurisdiction.VehicleClassificationDescription, actual.Jurisdiction.VehicleClassificationDescription, nameof(actual.Jurisdiction.VehicleClassificationDescription));
            Assert.AreEqual(expected.Jurisdiction.EndorsementCodeDescription, actual.Jurisdiction.EndorsementCodeDescription, nameof(actual.Jurisdiction.EndorsementCodeDescription));
            Assert.AreEqual(expected.Jurisdiction.RestrictionCodeDescription, actual.Jurisdiction.RestrictionCodeDescription, nameof(actual.Jurisdiction.RestrictionCodeDescription));

            Assert.AreEqual(expected.StandardVehicleClassification, actual.StandardVehicleClassification, nameof(actual.StandardVehicleClassification));
            Assert.AreEqual(expected.StandardEndorsementCode, actual.StandardEndorsementCode, nameof(actual.StandardEndorsementCode));
            Assert.AreEqual(expected.StandardRestrictionCode, actual.StandardRestrictionCode, nameof(actual.StandardRestrictionCode));
            Assert.AreEqual(expected.HazmatEndorsementExpirationDate, actual.HazmatEndorsementExpirationDate, nameof(actual.HazmatEndorsementExpirationDate));
        }
Beispiel #17
0
        public Connecticut() : base("CT")
        {
            var dl = new Rchar[9];

            dl[0] = new RcharLimited(0, '0');
            dl[1] = new RcharLimited(1, '1', '2', '3', '4', '5', '6', '7', '8', '9');
            Array.Copy(Numerics(7, 2), 0, dl, 2, 7);
            var dlf00 = new DriversLicense(dl, this);

            dl    = new Rchar[9];
            dl[0] = new RcharLimited(0, '1');
            Array.Copy(Numerics(8, 1), 0, dl, 1, 8);
            var dlf01 = new DriversLicense(dl, this);

            dl    = new Rchar[9];
            dl[0] = new RcharLimited(0, '2');
            dl[1] = new RcharLimited(1, '0', '1', '2', '3', '4');
            Array.Copy(Numerics(7, 2), 0, dl, 2, 7);
            var dlf02 = new DriversLicense(dl, this);

            dlFormats = new[] { dlf00, dlf01, dlf02 };
        }
Beispiel #18
0
 public Task <bool> Update(DriversLicense entity)
 {
     throw new NotImplementedException();
 }
Beispiel #19
0
    /// <summary>
    /// Manually add objects to the <see cref="SerializationInfo"/> store.
    /// </summary>
    public void GetObjectData(object obj, SerializationInfo info, StreamingContext context)
    {
        DriversLicense license = (DriversLicense)obj;

        info.AddValue("Number", license.Number);
    }
        static void Main()
        {
            Console.WriteLine("Reading barcode(s) from image {0}", Path.GetFullPath(InputFile));

            Reader reader = new Reader();

            reader.RegistrationName = "demo";
            reader.RegistrationKey  = "demo";

            // Set barcode type to find
            reader.BarcodeTypesToFind.PDF417 = true;

            /* -----------------------------------------------------------------------
            *  NOTE: We can read barcodes from specific page to increase performance.
            *  For sample please refer to "Decoding barcodes from PDF by pages" program.
            *  ----------------------------------------------------------------------- */

            // Read barcodes
            FoundBarcode[] barcodes = reader.ReadFrom(InputFile);

            if (barcodes.Length > 0)
            {
                FoundBarcode barcode = barcodes[0];

                // Get specific fields:

                IdentificationCard identificationCard = barcode.Metadata as IdentificationCard;

                if (identificationCard != null)
                {
                    Console.WriteLine("ID Numer: " + identificationCard.IdNumber);
                    Console.WriteLine("First Name: " + identificationCard.Name.First);
                    Console.WriteLine("Middle Name: " + identificationCard.Name.Middle);
                    Console.WriteLine("Last Name: " + identificationCard.Name.Last);
                    Console.WriteLine("Sex: " + identificationCard.Sex);
                    Console.WriteLine("Date Of Birth: " + identificationCard.DateOfBirth);
                    Console.WriteLine("Address: " + identificationCard.Address);

                    if (identificationCard is DriversLicense)
                    {
                        DriversLicense driverLicense = (DriversLicense)identificationCard;

                        Console.WriteLine("Vehicle Class: " + driverLicense.Jurisdiction.VehicleClass);
                        Console.WriteLine("Endorsement Codes: " + driverLicense.Jurisdiction.EndorsementCodes);
                        Console.WriteLine("Restriction Codes: " + driverLicense.Jurisdiction.RestrictionCodes);
                    }
                }
                else
                {
                    Console.WriteLine("Could not retrieve AAMVA data from this barcode. Raw value: \r\n" + barcode.Value);
                }

                // ... or get the full information as JSON:
                Console.WriteLine("\n\n-----------------\n");

                string jsonString = reader.ExportFoundBarcodesToJSON();
                Console.WriteLine(jsonString);
            }
            else
            {
                Console.WriteLine("No barcodes found!");
            }

            // Cleanup
            reader.Dispose();

            Console.WriteLine("Press any key to exit..");
            Console.ReadKey();
        }
Beispiel #21
0
        public void IndexSample(bool useServerSession)
        {
            string           brandName              = "Toyota";
            string           color                  = "Blue";
            int              maxPassengers          = 5;
            int              fuelCapacity           = 40;
            double           litresPer100Kilometers = 5;
            DateTime         modelYear              = new DateTime(2003, 1, 1);
            string           modelName              = "Highlander";
            int              maxSpeed               = 200;
            int              odometer               = 100000;
            string           registrationState      = "Texas";
            string           registrationPlate      = "TX343434";
            string           insurancePolicy        = "CAA7878787";
            DriversLicense   license                = new DriversLicense("California", "B7788888", DateTime.Now + new TimeSpan(1825, 0, 0, 0));
            Person           person                 = new Person("Mats Persson", license);
            InsuranceCompany insuranceCompany       = new InsuranceCompany("Allstate", "858727878");
            Car              car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, maxSpeed,
                                           odometer, registrationState, registrationPlate, insuranceCompany, insurancePolicy);

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                foreach (Database db in session.OpenAllDatabases(true))
                {
                    if (db.DatabaseNumber >= 10 || db.DatabaseNumber == SessionBase.IndexDescriptorDatabaseNumber)
                    {
                        session.DeleteDatabase(db);
                    }
                }
                session.Commit();

                session.BeginUpdate();
                DatabaseLocation defaultLocation = session.DatabaseLocations.Default();
                List <Database>  dbList          = session.OpenLocationDatabases(defaultLocation, true);
                foreach (Database db in dbList)
                {
                    if (db.DatabaseNumber > Database.InitialReservedDatabaseNumbers)
                    {
                        session.DeleteDatabase(db);
                    }
                }
                session.DeleteLocation(defaultLocation);
                session.Commit();
                CreateDirectoryAndCopyLicenseDb();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginRead();
                int ct     = 0;
                var mIndex = session.Index <Motorcycle>();
                if (mIndex != null)
                {
                    foreach (Motorcycle mc in session.Index <Motorcycle>())
                    {
                        Assert.NotNull(mc);
                        ++ct;
                    }
                }
                Assert.AreEqual(ct, 0);
                session.Commit();
            }
            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                for (int i = 0; i < 10000; i++)
                {
                    Motorcycle mc = new Motorcycle();
                    session.Persist(mc);
                }
                session.Commit();
                session.BeginUpdate();
                int ct     = 0;
                var mIndex = session.Index <Car>();
                if (mIndex != null)
                {
                    foreach (Car c in mIndex)
                    {
                        Assert.NotNull(c);
                        ++ct;
                    }
                }
                Assert.AreEqual(ct, 0);
                ct = 0;
                session.RegisterClass(typeof(Person));
                foreach (Person p in session.AllObjects <Person>(true, false))
                {
                    Assert.NotNull(p);
                    ++ct;
                }
                session.Commit();
                session.BeginRead();
                ct = 0;
                foreach (Motorcycle mc in session.AllObjects <Motorcycle>(false, true))
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 10000);
                session.Commit();
                session.BeginRead();
                ct = 0;
                foreach (Motorcycle mc in session.AllObjects <Motorcycle>(false, true))
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 10000);
                session.Abort();
                session.BeginRead();
                ct = 0;
                foreach (Motorcycle mc in session.AllObjects <Motorcycle>(false, true))
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 10000);
                session.Commit();
                session.BeginRead();
                ct = 0;
                foreach (Motorcycle mc in session.Index <Motorcycle>())
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 10000);
                session.Abort();
                session.BeginRead();
                ct = 0;
                foreach (Motorcycle mc in session.Index <Motorcycle>())
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 10000);
                session.Commit();
                try
                {
                    ct = 0;
                    foreach (Motorcycle mc in session.Index <Motorcycle>())
                    {
                        Assert.NotNull(mc);
                        ++ct;
                    }
                    Assert.AreEqual(ct, 10000);
                }
                catch (NotInTransactionException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                session.BeginUpdate();
                ct = 0;
                foreach (Motorcycle mc in session.AllObjects <Motorcycle>(false, true))
                {
                    if (++ct % 2 == 0)
                    {
                        mc.Unpersist(session);
                    }
                }
                ct = 0;
                foreach (Motorcycle mc in session.Index <Motorcycle>())
                {
                    ++ct;
                }
                Assert.AreEqual(ct, 5000);
                session.Abort();
                session.BeginUpdate();
                ct = 0;
                foreach (Motorcycle mc in session.AllObjects <Motorcycle>(false, true))
                {
                    if (++ct % 2 == 0)
                    {
                        mc.Unpersist(session);
                    }
                }
                ct = 0;
                foreach (Motorcycle mc in session.Index <Motorcycle>())
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 5000);
                ct = 0;
                foreach (Motorcycle mc in session.Index <Motorcycle>("cc"))
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 5000);
                ct = 0;
                try
                {
                    foreach (Motorcycle mc in session.Index <Motorcycle>("ccx"))
                    {
                        Assert.NotNull(mc);
                        ++ct;
                    }
                    Assert.AreEqual(ct, 5000);
                }
                catch (FieldDoesNotExistException)
                {
                }
                session.Commit();
                session.BeginUpdate();
                ct = 0;
                double prior = -44.0;
                foreach (Motorcycle mc in session.Index <Motorcycle>("cc"))
                {
                    Assert.NotNull(mc);
                    mc.CC = mc.CC - prior;
                    prior = mc.CC;
                    ++ct;
                }
                Assert.AreEqual(ct, 2500);
                for (int i = 0; i < 95000; i++)
                {
                    Motorcycle mc = new Motorcycle();
                    session.Persist(mc);
                }
                session.FlushUpdates();
                ct = 0;
                foreach (Motorcycle mc in session.Index <Motorcycle>())
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 100000);
                session.Abort();
                session.BeginUpdate();
                ct    = 0;
                prior = double.MinValue;
                foreach (Motorcycle mc in session.Index <Motorcycle>("cc"))
                {
                    Assert.NotNull(mc);
                    Assert.GreaterOrEqual(mc.CC, prior);
                    prior = mc.CC;
                    ++ct;
                    if (ct < 25)
                    {
                        Console.Write(prior.ToString() + " ");
                    }
                }
                ct    = 0;
                prior = -44.0;
                foreach (Motorcycle mc in session.Index <Motorcycle>("cc"))
                {
                    Assert.NotNull(mc);
                    mc.CC = mc.CC - prior;
                    prior = mc.CC;
                    ++ct;
                }
                Assert.AreEqual(ct, 2500);
                session.Commit();
                session.BeginUpdate();
                ct    = 0;
                prior = double.MinValue;
                foreach (Motorcycle mc in session.Index <Motorcycle>("cc"))
                {
                    Assert.NotNull(mc);
                    Assert.GreaterOrEqual(mc.CC, prior);
                    prior = mc.CC;
                    ++ct;
                }
                for (int i = 0; i < 95000; i++)
                {
                    Motorcycle mc = new Motorcycle();
                    session.Persist(mc);
                    DataBaseFileEntry dbEntry = new DataBaseFileEntry {
                        Something = "Something"
                    };
                    session.Persist(dbEntry);
                    mc.AddChild(dbEntry);
                    mc.AddChild(dbEntry);
                }
                session.FlushUpdates();
                ct = 0;
                foreach (Motorcycle mc in session.Index <Motorcycle>())
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 100000);
                session.Commit();
                session.BeginRead();
                session.Abort();
                session.BeginUpdate();
                foreach (Motorcycle mc in session.Index <Motorcycle>())
                {
                    Assert.NotNull(mc);
                    VelocityDbList <DataBaseFileEntry> children = mc.Children;
                    if (children != null && children.Count > 0)
                    {
                        mc.RemoveChild(children[0]);
                    }
                    ++ct;
                }
                session.Commit();
                session.BeginRead();
                ct    = 0;
                prior = double.MinValue;
                foreach (Motorcycle mc in session.Index <Motorcycle>("cc"))
                {
                    Assert.NotNull(mc);
                    Assert.GreaterOrEqual(mc.CC, prior);
                    prior = mc.CC;
                    ++ct;
                }
                Assert.AreEqual(ct, 100000);
                session.Commit();
                Console.WriteLine("Motorcycle index Test OK");
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                session.Persist(car);
                registrationState = "Maine";
                car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, maxSpeed,
                              odometer, registrationState, registrationPlate, insuranceCompany, insurancePolicy);
                session.Persist(car);
                color                  = "Red";
                maxPassengers          = 5;
                fuelCapacity           = 50;
                litresPer100Kilometers = 8;
                modelYear              = new DateTime(2006, 1, 1);
                brandName              = "Toyota";
                modelName              = "Tacoma";
                maxSpeed               = 210;
                odometer               = 50000;
                registrationState      = "Texas";
                registrationPlate      = "TX343433";
                insurancePolicy        = "CAA7878777";
                car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, maxSpeed,
                              odometer, registrationState, registrationPlate, insuranceCompany, insurancePolicy);
                session.Persist(car);
                color                  = "Black";
                maxPassengers          = 5;
                fuelCapacity           = 60;
                litresPer100Kilometers = 3;
                modelYear              = new DateTime(2001, 1, 1);
                brandName              = "Lincoln";
                modelName              = "Town Car";
                maxSpeed               = 220;
                odometer               = 250000;
                registrationState      = "Texas";
                registrationPlate      = "TX543433";
                insurancePolicy        = "CAA7878775";
                for (int i = 0; i < 1; i++)
                {
                    registrationState = RandomString(2);
                    registrationPlate = RandomString(12);
                    car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, maxSpeed, odometer, registrationState, registrationPlate, insuranceCompany, insurancePolicy);
                    session.Persist(car);
                    color                  = null;
                    maxPassengers          = i;
                    fuelCapacity           = 60;
                    litresPer100Kilometers = 3;
                    modelYear              = new DateTime(2001, 1, 1);
                    brandName              = "Null Car";
                    modelName              = null;
                    maxSpeed               = 220;
                    odometer               = 250000;
                    insurancePolicy        = null;
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginRead();
                Console.WriteLine("Blue Cars");
                BTreeSet <Car> bTree = session.Index <Car>("color");
                foreach (Car c in (from aCar in bTree where aCar.Color == "Blue" select aCar))
                {
                    Console.WriteLine(c.ToStringDetails(session));
                }
                Console.WriteLine("Cars in fuel efficierncy order");
                foreach (Car c in session.Index <Car>("litresPer100Kilometers"))
                {
                    Console.WriteLine(c.ToStringDetails(session));
                }
                Console.WriteLine("Vehicles ordered modelYear, brandName, modelName, color");
                foreach (Vehicle v in session.Index <Vehicle>())
                {
                    Console.WriteLine(v.ToStringDetails(session));
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                // these LINQ statements will trigger a binary search lookup (not a linear serach) of the matching Car objects in the BTreeSet
                Car c = (from aCar in session.Index <Car>("color") where aCar.Color == "Blue" select aCar).First();
                c.Color = "Green";
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                // these LINQ statements will trigger a binary search lookup (not a linear serach) of the matching Car objects in the BTreeSet
                Car    c  = (from aCar in session.Index <Car>("color") where aCar.Color == "Green" select aCar).First();
                UInt64 id = c.Id;
                session.DeleteObject(id);
                session.Abort();
                session.BeginUpdate();
                session.DeleteObject(id);
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();
                session.BeginRead();
                // these LINQ statements will trigger a binary search lookup (not a linear serach) of the matching Car objects in the BTreeSet
                Console.WriteLine("Blue Cars");
                foreach (Car c in (from aCar in session.Index <Car>("color") where aCar.Color == "Blue" select aCar))
                {
                    Console.WriteLine(c.ToStringDetails(session));
                }
                session.Commit();
                sw.Stop();
                Console.WriteLine(sw.Elapsed);
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                for (int i = 0; i < 10000; i++)
                { // add some junk to make search harder
                    car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, i,
                                  odometer, registrationState, registrationPlate + i, insuranceCompany, insurancePolicy);
                    session.Persist(car);
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginRead();
                // these LINQ statements will trigger a binary search lookup (not a linear serach) of the matching Car objects in the BTreeSet
                Console.WriteLine("Blue Cars");
                foreach (Car c in (from aCar in session.Index <Car>("color") where aCar.Color == "Blue" select aCar))
                {
                    Console.WriteLine(c.ToStringDetails(session));
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                Car c = (from aCar in session.Index <Car>("color") where aCar.Color == "Blue" select aCar).First();
                c.Unpersist(session);
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginRead();
                foreach (Car c in session.Index <Car>())
                {
                    Console.WriteLine(c.ToStringDetails(session));
                }
                Console.WriteLine("Blue Cars");
                foreach (Car c in (from aCar in session.Index <Car>() where aCar.Color == "Blue" select aCar))
                {
                    Console.WriteLine(c.ToStringDetails(session));
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                InsuranceCompany prior = insuranceCompany;
                try
                {
                    for (int i = 0; i < 100000; i++)
                    {
                        insuranceCompany = new InsuranceCompany("AAA", "858787878");
                        insuranceCompany.Persist(session, prior);
                        prior = insuranceCompany;
                    }
                    Assert.IsTrue(false); // should not get here
                }
                catch (UniqueConstraintException)
                {
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginRead();
                Database db = session.OpenDatabase(session.DatabaseNumberOf(typeof(InsuranceCompany)));
                var      q  = from company in session.Index <InsuranceCompany>("name", db) where company.Name == "AAA" select company;
                foreach (InsuranceCompany company in q)
                {
                    Console.WriteLine(company.ToStringDetails(session)); // only one will match
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                InsuranceCompany prior = insuranceCompany;
                try
                {
                    for (int i = 0; i < 100000; i++)
                    {
                        insuranceCompany = new InsuranceCompany("AAA", "858787878");
                        session.Persist(insuranceCompany);
                    }
                    Assert.IsTrue(false); // should not get here
                }
                catch (UniqueConstraintException)
                {
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginRead();
                Database db = session.OpenDatabase(session.DatabaseNumberOf(typeof(InsuranceCompany)));
                var      q  = from company in session.Index <InsuranceCompany>("name", db) where company.Name == "AAA" select company;
                foreach (InsuranceCompany company in q)
                {
                    Console.WriteLine(company.ToStringDetails(session)); // only one will match
                }
                bool exists = (from anEntry in session.Index <InsuranceCompany>("name", db) where anEntry.Name == "AAA" select 0).Any();
                Assert.IsTrue(exists);
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                try
                {
                    for (int i = 0; i < 100000; i++)
                    {
                        insuranceCompany = new InsuranceCompanySpecial("AAA", "858787878");
                        session.Persist(insuranceCompany);
                    }
                    Assert.IsTrue(false); // should not get here
                }
                catch (UniqueConstraintException)
                {
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                try
                {
                    for (int i = 0; i < 100000; i++)
                    {
                        insuranceCompany = new InsuranceCompanySpecial2("AAA", "858787878");
                        session.Persist(insuranceCompany);
                    }
                    Assert.IsTrue(false); // should not get here
                }
                catch (UniqueConstraintException)
                {
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginRead();
                Database db = session.OpenDatabase(session.DatabaseNumberOf(typeof(InsuranceCompanySpecial)));
                var      q  = from company in session.Index <InsuranceCompany>("name", db) where company.Name == "AAA" select company;
                foreach (InsuranceCompany company in q)
                {
                    Console.WriteLine(company.ToStringDetails(session)); // only one will match
                }
                bool exists = (from anEntry in session.Index <InsuranceCompanySpecial>("name", db) where anEntry.Name == "AAA" select 0).Any();
                Assert.IsTrue(exists);
                session.Commit();
            }
        }
Beispiel #22
0
 public void UpdateDriversLicense(DriversLicense driversLicense) => DriversLicense = driversLicense;
Beispiel #23
0
        static readonly string s_systemDir     = "Indexes"; // appended to SessionBase.BaseDatabasePath

        static void Main(string[] args)
        {
            try
            {
                Trace.Listeners.Add(new ConsoleTraceListener());
                string           brandName              = "Toyota";
                string           color                  = "Blue";
                int              maxPassengers          = 5;
                int              fuelCapacity           = 40;
                double           litresPer100Kilometers = 5;
                DateTime         modelYear              = new DateTime(2003, 1, 1);
                string           modelName              = "Highlander";
                int              maxSpeed               = 200;
                int              odometer               = 100000;
                string           registrationState      = "Texas";
                string           registrationPlate      = "TX343434";
                string           insurancePolicy        = "CAA7878787";
                DriversLicense   license                = new DriversLicense("California", "B7788888", DateTime.Now + new TimeSpan(1825, 0, 0, 0));
                Person           person                 = new Person("Mats Persson", license);
                InsuranceCompany insuranceCompany       = new InsuranceCompany("Allstate", "858727878");
                Car              car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, maxSpeed,
                                               odometer, registrationState, registrationPlate, insuranceCompany, insurancePolicy);
                using (SessionNoServer session = new SessionNoServer(s_systemDir))
                { // cleanup data from a possible prior run
                    session.BeginUpdate();
                    foreach (Database db in session.OpenAllDatabases(true))
                    {
                        if (db.DatabaseNumber >= 10 || db.DatabaseNumber == SessionBase.IndexDescriptorDatabaseNumber)
                        {
                            session.DeleteDatabase(db);
                        }
                    }
                    session.Commit();
                    File.Copy(s_licenseDbFile, Path.Combine(session.SystemDirectory, "4.odb"));
                }
                using (SessionNoServer session = new SessionNoServer(s_systemDir))
                {
                    Console.WriteLine("Running with databases in directory: " + session.SystemDirectory);
                    //session.AddToIndexInSeperateThread = false;
                    session.BeginUpdate();
                    session.Persist(car);
                    registrationState = "Maine";
                    car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, maxSpeed,
                                  odometer, registrationState, registrationPlate, insuranceCompany, insurancePolicy);
                    session.Persist(car);
                    color                  = "Red";
                    maxPassengers          = 5;
                    fuelCapacity           = 50;
                    litresPer100Kilometers = 8;
                    modelYear              = new DateTime(2006, 1, 1);
                    brandName              = "Toyota";
                    modelName              = "Tacoma";
                    maxSpeed               = 210;
                    odometer               = 50000;
                    registrationState      = "Texas";
                    registrationPlate      = "TX343433";
                    insurancePolicy        = "CAA7878777";
                    car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, maxSpeed,
                                  odometer, registrationState, registrationPlate, insuranceCompany, insurancePolicy);
                    session.Persist(car);
                    color                  = "Black";
                    maxPassengers          = 5;
                    fuelCapacity           = 60;
                    litresPer100Kilometers = 3;
                    modelYear              = new DateTime(2001, 1, 1);
                    brandName              = "Lincoln";
                    modelName              = "Town Car";
                    maxSpeed               = 220;
                    odometer               = 250000;
                    registrationState      = "Texas";
                    registrationPlate      = "TX543433";
                    insurancePolicy        = "CAA7878775";
                    car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, maxSpeed,
                                  odometer, registrationState, registrationPlate, insuranceCompany, insurancePolicy);
                    session.Persist(car);
                    session.Commit();
                }
                using (SessionNoServer session = new SessionNoServer(s_systemDir))
                {
                    session.BeginRead();
                    Console.WriteLine("Blue Cars");
                    BTreeSet <Car> bTree = session.Index <Car>("color");
                    foreach (Car c in (from aCar in bTree where aCar.Color == "Blue" select aCar))
                    {
                        Console.WriteLine(c.ToStringDetails(session));
                    }
                    Console.WriteLine("Cars in fuel efficiency order");
                    foreach (Car c in session.Index <Car>("litresPer100Kilometers"))
                    {
                        Console.WriteLine(c.ToStringDetails(session));
                    }
                    Console.WriteLine("Vehicles ordered modelYear, brandName, modelName, color");
                    foreach (Vehicle v in session.Index <Vehicle>())
                    {
                        Console.WriteLine(v.ToStringDetails(session));
                    }
                    session.Commit();
                }
                using (SessionNoServer session = new SessionNoServer(s_systemDir))
                {
                    session.TraceIndexUsage = true;
                    session.BeginUpdate();
                    // these LINQ statements will trigger a binary search lookup (not a linear search) of the matching Car objects in the BTreeSet
                    Car c = (from aCar in session.Index <Car>("color") where aCar.Color == "Blue" select aCar).First();
                    c.Color = "Green";
                    session.Commit();
                }
                using (SessionNoServer session = new SessionNoServer(s_systemDir))
                {
                    session.TraceIndexUsage = true;
                    session.BeginUpdate();
                    // these LINQ statements will trigger a binary search lookup (not a linear search) of the matching Car objects in the BTreeSet
                    Car    c  = (from aCar in session.Index <Car>("color") where aCar.Color == "Green" select aCar).First();
                    UInt64 id = c.Id;
                    session.DeleteObject(id);
                    session.Abort();
                    session.BeginUpdate();
                    session.DeleteObject(id);
                    session.Commit();
                }
                using (SessionNoServer session = new SessionNoServer(s_systemDir))
                {
                    session.TraceIndexUsage = true;
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    session.BeginRead();
                    // these LINQ statements will trigger a binary search lookup (not a linear search) of the matching Car objects in the BTreeSet
                    Console.WriteLine("Blue Cars");
                    foreach (Car c in (from aCar in session.Index <Car>("color") where aCar.Color == "Blue" select aCar))
                    {
                        Console.WriteLine(c.ToStringDetails(session));
                    }
                    session.Commit();
                    sw.Stop();
                    Console.WriteLine(sw.Elapsed);
                }
                using (SessionNoServer session = new SessionNoServer(s_systemDir))
                {
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    session.BeginUpdate();
                    for (int i = 0; i < 10000; i++)
                    { // add some junk to make search harder
                        car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, i,
                                      odometer, registrationState, registrationPlate + i, insuranceCompany, insurancePolicy);
                        session.Persist(car);
                    }
                    session.Commit();
                    sw.Stop();
                    Console.WriteLine(sw.Elapsed);
                }
                using (SessionNoServer session = new SessionNoServer(s_systemDir))
                {
                    session.TraceIndexUsage = true;
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    session.BeginRead();
                    // these LINQ statements will trigger a binary search lookup (not a linear search) of the matching Car objects in the BTreeSet
                    Console.WriteLine("Blue Cars");
                    foreach (Car c in (from aCar in session.Index <Car>("color") where aCar.Color == "Blue" select aCar))
                    {
                        Console.WriteLine(c.ToStringDetails(session));
                    }
                    session.Commit();
                    sw.Stop();
                    Console.WriteLine(sw.Elapsed);
                }
                using (SessionNoServer session = new SessionNoServer(s_systemDir))
                {
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    session.BeginUpdate();
                    Car c = (from aCar in session.Index <Car>("color") where aCar.Color == "Blue" select aCar).First();
                    c.Unpersist(session);
                    session.Commit();
                    sw.Stop();
                    Console.WriteLine(sw.Elapsed);
                }
                using (SessionNoServer session = new SessionNoServer(s_systemDir))
                {
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    session.BeginRead();
                    foreach (Car c in session.Index <Car>())
                    {
                        Console.WriteLine(c.ToStringDetails(session));
                    }
                    Console.WriteLine("Blue Cars");
                    foreach (Car c in (from aCar in session.Index <Car>() where aCar.Color == "Blue" select aCar))
                    {
                        Console.WriteLine(c.ToStringDetails(session));
                    }
                    session.Commit();
                    sw.Stop();
                    Console.WriteLine(sw.Elapsed);
                }
                using (SessionNoServer session = new SessionNoServer(s_systemDir))
                {
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    session.BeginUpdate();
                    InsuranceCompany prior = insuranceCompany;
                    try
                    {
                        for (int i = 0; i < 100000; i++)
                        {
                            insuranceCompany = new InsuranceCompany("AAA", "858787878");
                            session.Persist(insuranceCompany);
                        }
                        Debug.Assert(false); // should not get here
                    }
                    catch (UniqueConstraintException)
                    {
                    }
                    session.Commit();
                    sw.Stop();
                    Console.WriteLine(sw.Elapsed);
                }
                using (SessionNoServer session = new SessionNoServer(s_systemDir))
                {
                    session.TraceIndexUsage = true;
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    session.BeginRead();
                    Database db = session.OpenDatabase(session.DatabaseNumberOf(typeof(InsuranceCompany)));
                    var      q  = from company in session.Index <InsuranceCompany>("name", db) where company.Name == "AAA" select company;
                    foreach (InsuranceCompany company in q)
                    {
                        Console.WriteLine(company.ToStringDetails(session)); // only one will match
                    }
                    session.Commit();
                    sw.Stop();
                    Console.WriteLine(sw.Elapsed);
                }

                using (SessionNoServer session = new SessionNoServer(s_systemDir))
                {
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    session.BeginUpdate();
                    Customer joe = new Customer("Joe");
                    session.Persist(joe);
                    Customer karim = new Customer("Karim");
                    session.Persist(karim);
                    Customer tony = new Customer("Tony");
                    session.Persist(tony);
                    Customer wayne = new Customer("Wayne");
                    session.Persist(wayne);
                    Order   order   = new Order(joe);
                    Payment payment = new Payment(order);
                    order   = new Order(karim);
                    payment = new Payment(order);
                    payment = new Payment(order);
                    payment = new Payment(order);
                    order   = new Order(tony);
                    payment = new Payment(order);
                    payment = new Payment(order);
                    order   = new Order(wayne);
                    payment = new Payment(order);
                    session.Commit();
                    sw.Stop();
                    Console.WriteLine(sw.Elapsed);
                }

                using (SessionNoServer session = new SessionNoServer(s_systemDir))
                {
                    session.TraceIndexUsage = true;
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    session.BeginRead();
                    var karim                = (from customer in session.Index <Customer>("m_name") where customer.Name == "Karim" select customer).FirstOrDefault();
                    var karimOrders          = karim.Orders;
                    var karimOrderFromOrders = (from order in session.Index <Order>("m_customer") where order.Customer == karim select order).ToArray();
                    session.Commit();
                    session.BeginUpdate();
                    karim = (from customer in session.Index <Customer>("m_name") where customer.Name == "Karim" select customer).FirstOrDefault();
                    karim.StreetAddress = "1623 Bonita Ave";
                    session.Commit();
                    sw.Stop();
                    Console.WriteLine(sw.Elapsed);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }