class Employee { public int id; public string name; public int getID { get { return id; } set { id = value; } } public string SayHello() { return string.Format("'Hello World!', said {0}.", name); } public string getName { get { return name; } set { name = value; } } }
static void Main(string[] args) { //Employee fred = new Employee(); //fred.name = "Tran Tuan Van"; //Console.WriteLine(fred.SayHello()); CreateEmployeeAndSaveToDatabase(); // UpdateTobinAndAssignPierreHenriAsManager(); // LoadEmployeesFromDatabase(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); Console.ReadKey(); } static void CreateEmployeeAndSaveToDatabase() { Employee tobin = new Employee(); tobin.name = "Tobin Harris"; tobin.id = 1; using (ISession session = OpenSession()) { try { using (ITransaction transaction = session.BeginTransaction()) { session.Save(tobin); transaction.Commit(); } } catch (Exception ex) { } Console.WriteLine("Saved Tobin to the database"); } }