示例#1
0
        private void AddData()
        {
            ISession session = sessionFactory.OpenSession();

            try
            {
                session.BeginTransaction();
                var report = new WeatherReport
                {
                    Continent   = "North America",
                    Latitude    = 25,
                    Longitude   = 30,
                    ReportTime  = DateTime.Now,
                    Temperature = 44
                };
                session.Save(report);

                report = new WeatherReport
                {
                    Continent   = "Africa",
                    Latitude    = 44,
                    Longitude   = 99,
                    ReportTime  = DateTime.Now,
                    Temperature = 31
                };
                session.Save(report);

                report = new WeatherReport
                {
                    Continent   = "Asia",
                    Latitude    = 13,
                    Longitude   = 12,
                    ReportTime  = DateTime.Now,
                    Temperature = 104
                };
                session.Save(report);
                session.Transaction.Commit();
            }
            finally
            {
                session.Close();
            }
        }
        private void AddData()
        {
            ISession session = sessionFactory.OpenSession();
            try
            {
                session.BeginTransaction();
                var report = new WeatherReport
                {
                    Continent = "North America",
                    Latitude = 25,
                    Longitude = 30,
                    ReportTime = DateTime.Now,
                    Temperature = 44
                };
                session.Save(report);

                report = new WeatherReport
                {
                    Continent = "Africa",
                    Latitude = 44,
                    Longitude = 99,
                    ReportTime = DateTime.Now,
                    Temperature = 31
                };
                session.Save(report);

                report = new WeatherReport
                {
                    Continent = "Asia",
                    Latitude = 13,
                    Longitude = 12,
                    ReportTime = DateTime.Now,
                    Temperature = 104
                };
                session.Save(report);
                session.Transaction.Commit();
            }
            finally
            {
                session.Close();
            }
        }