Example #1
0
 private static void CreateEmployeeAndSave()
 {
     var tobin = new Employee {Name = "Tobin Harris"};
     using (var session = OpenSession())
     {
         using (var transaction = session.BeginTransaction())
         {
             session.Save(tobin);
             transaction.Commit();
         }
     }
 }
Example #2
0
        private static void UpdateTobinAndAssignPierre()
        {
            using (var session = OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    var query = session.CreateQuery("from Employee where Name='Tobin Harris'");
                    var tobin = query.List<Employee>()[0];
                    tobin.Name = "Tobin David Harris";

                    var pierre = new Employee {Name = "Pierre Henri Kuate"};
                    tobin.Manager = pierre;
                    transaction.Commit();
                    Console.WriteLine("Updated Tobin and added Pierre");
                }
            }
        }