public static void Main(string[] args) { ISessionFactory sessionFactory = new Configuration().Configure().BuildSessionFactory(); Expense e = new Expense(); Provider p = new Provider(sessionFactory.OpenSession()); e = p.GetExpenseById(1); e.Date = new DateTime(2009, 1, 18); e.Description = "description"; e.Amount = 100; //e.ExpenseTypeId = 1; using(var session = sessionFactory.OpenSession()) using(session.BeginTransaction()) { session.Save(e); session.Transaction.Commit(); } // Expense e = new Expense(); // // // // Provider p = new Provider(); // e = p.GetExpenseById(1); // // Console.Write(e.Id); // Console.Write(e.Description); // Console.Write(e.Amount); // // Mono.Data.Sqlite.SqliteConnection conn = new Mono.Data.Sqlite.SqliteConnection("Data Source=database.sqlite3"); // Mono.Data.Sqlite.SqliteCommand cmd = new Mono.Data.Sqlite.SqliteCommand("select * from expenses", conn); // conn.Open(); // Mono.Data.Sqlite.SqliteDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); // string s = ""; // while(rdr.Read()) // { // s+=rdr.ToString(); // } // // // Application.Init (); MainWindow win = new MainWindow (); win.Show (); Application.Run (); }
static void Main(string[] args) { // initialize profiler integration NHibernateProfiler.Initialize(); try { // the session factory is the entry point to NHibernate var sessionFactory = new Configuration() .Configure("nhibernate.cfg.xml") .BuildSessionFactory(); // the session is what we use to actually using (var session = sessionFactory.OpenSession()) using (var tx = session.BeginTransaction()) { tx.Commit(); } } finally { // we need this so we wouldn't exit the process // before all the work was sent to the profiler ProfilerInfrastructure.FlushAllMessages(); } }
public void SessionWithComplexTransactionsTest2() { var SessionFactory = new Configuration().Configure() //.SetNamingStrategy() .BuildSessionFactory(); ISession session = SessionFactory.OpenSession(); CreateNewEntity(session); //cats.Add(entity); CreateNewEntity(session); Console.WriteLine("Succeed!"); session.Flush(); }
static void Main(string[] args) { var nhSessionFactory = new NHibernate.Cfg.Configuration() // .AddAutoMappings() .DropDatabaseTables() .CreateDatabaseTables() .BuildSessionFactory(); var start = DateTime.Now; for (int i = 0; i < 100; i++) { using (var session = nhSessionFactory.OpenSession()) { using (var tx = session.BeginTransaction()) { tx.Commit(); } } } var end = DateTime.Now; int breaasd = 0; }