Ejemplo n.º 1
0
        public static void CreatePeople()
        {
            Console.WriteLine("--- CREATING A LIST OF PEOPLE ---");

            var address = new Address
                              {
                                  Line1 = "123 Some St.",
                                  City = "Grimes",
                                  State = "Iowa",
                                  Zip = "50111"
                              };

            ISession session = GetSession();
            session.Save(address);

            for (int i = 0; i < 10; i++)
            {
                var person = new Person
                                 {
                                     FullName =
                                         {
                                             FirstName = "Person",
                                             MiddleName = i.ToString(),
                                             LastName = "Test" + i
                                         },
                                     Address = address
                                 };

                session.Save(person);
            }

            session.Flush();
            session.Dispose();
        }
Ejemplo n.º 2
0
        private static void GetOnePerson()
        {
            Console.WriteLine("--- GETTING ONE PERSON ---");

            using (ISession session = GetSession())
            {
                var address = new Address
                                  {
                                      Line1 = "123 Some St.",
                                      City = "Grimes",
                                      State = "Iowa",
                                      Zip = "50111"
                                  };

                session.Save(address);

                var person = new Person
                                 {
                                     FullName =
                                         {
                                             FirstName = "Javier",
                                             MiddleName = "G",
                                             LastName = "Lozano"
                                         },
                                     Address = address
                                 };

                session.Save(person);
                session.Flush();
            }

            using (ISession session = GetSession())
            {
                IQuery query = session.CreateQuery("from Person p where p.FullName.LastName = :lastName");
                query.SetString("lastName", "Lozano");

                var person = query.UniqueResult<Person>();

                Console.WriteLine("Name: {0}", person.FullName);
                Console.WriteLine("Address: {0}", person.Address);
            }
        }
Ejemplo n.º 3
0
 public Person()
 {
     FullName = new Name();
     Address = new Address();
 }