Пример #1
0
        static void Main(string[] args)
        {
            var nhinit = new NHibernateInitializer();

            nhinit.Initialize();
            nhinit.CreateSchema();
            var sf = nhinit.SessionFactory;

            //using(var s = sf.OpenSession())
            //using (var tx = s.BeginTransaction())
            //{
            //  tx.Commit();
            //}

            Console.WriteLine("Work done!");
            Console.ReadLine();
            sf.Close();
            nhinit.DropSchema();
        }
        static void Main(string[] args)
        {
            var nhinit = new NHibernateInitializer();
            nhinit.Initialize();
            nhinit.CreateSchema();
            var sf = nhinit.SessionFactory;

            using (var s = sf.OpenSession())
            using (var tx = s.BeginTransaction())
            {
                var p = new Persona();
                p.Nombre = "Daniel";
                p.Apellido = "Alvarez";
                s.Save(p);

                tx.Commit();
            }

            Console.WriteLine("Work done!");
            Console.ReadLine();
            sf.Close();
            nhinit.DropSchema();
        }
        static void Main(string[] args)
        {
            var nhinit = new NHibernateInitializer();

            nhinit.Initialize();
            nhinit.CreateSchema();
            var sf = nhinit.SessionFactory;

            using (var s = sf.OpenSession())
                using (var tx = s.BeginTransaction())
                {
                    var p = new Persona();
                    p.Nombre   = "Daniel";
                    p.Apellido = "Alvarez";
                    s.Save(p);

                    tx.Commit();
                }

            Console.WriteLine("Work done!");
            Console.ReadLine();
            sf.Close();
            nhinit.DropSchema();
        }