示例#1
0
        public void ChangeTheNameOfTheCatFromSmellyToUgly()
        {
            Cat smellyCat;
            using (var session = OpenSession())
            {
                var john = session.Get<Person>(nicePersonId);
                john.AddCat(new Cat(john) { Name = "Whisky" });

                var johnJunior = new Child("John Junior",john) { NickName = "John's FirstBorn" };
                john.AddChild(johnJunior);

                smellyCat = new Cat(johnJunior) {Name = "Smelly Cat"};
                johnJunior.AddCat(smellyCat);

                session.Flush();
                session.Clear();
            }

            using (var session = OpenSession())
            {
                smellyCat = session.Get<Cat>(smellyCat.Id);
                smellyCat.Name = "Ugly cat";
                session.Flush();               //if you change the PreUpdateEventListenerImpl to Log.Info on the Master.Name you get an exception
            }
        }
示例#2
0
文件: Person.cs 项目: kriebb/NH-2873
 public virtual void AddCat(Cat cat)
 {
     cats.Add(cat);
 }