using Myhib = NHibernate;
using System;
//using User;
using Myhibc = NHibernate.Cfg;
public class Hibexample {
public Hibexample() {
Myhibc.Configuration cfg = new Myhibc.Configuration();
cfg.AddAssembly("NHibernate.Examples");
ISessionFactory factory = cfg.BuildSessionFactory();
}
public static void Main(String []args) {
Hibexample hibex = new Hibexample();
hibex.loadObject();
}
public void loadObject() {
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();
User newUser = new User();
newUser.Id = "joe_cool";
newUser.UserName = "Joseph Cool";
newUser.Password = "abc123";
newUser.EmailAddress = "
[email protected]";
newUser.LastLogon = DateTime.Now;
// Tell NHibernate that this object should be saved
session.Save(newUser);
// commit all of the changes to the DB and close the ISession
transaction.Commit();
session.Close();
}
}