Example #1
0
        public void test_connection()
        {
            Console.WriteLine(TimeZoneInfo.Local.Id);

            using (var session = CreateLogTimesheetSessionFactory().OpenSession())
            using (var tran = session.BeginTransaction())
            {
                //var dhing = (from x in session.Query<Player>()
                //             where x.Name == "Dhing"
                //             select x).FirstOrDefault();
                var p = new Player()
                {
                    Name = "Dhing",
                    //CreatedDate = DateTime.UtcNow
                };

                session.Save(p);

                tran.Commit();
            }
        }
Example #2
0
        public void test_connection_ef()
        {
            Console.WriteLine(TimeZoneInfo.Local.Id);

            Database.SetInitializer(new DropCreateDatabaseAlways<HRContext>());

            using (var hr_context = new HRContext())
            //using(var tran = hr_context.Database.BeginTransaction())
            {
                //hr_context.Database.CreateIfNotExists();
                //var dhing = (from x in hr_context.Players
                //             where x.Name == "Dhing"
                //             select x).FirstOrDefault();

                //dhing.CreatedDate = DateTime.Now;
                var p = new Player()
                {
                    Id= 3,
                    Name = "Dhing",
                    CreatedDate = DateTime.Now
                };

                hr_context.Players.Add(p);
                hr_context.SaveChanges();
                //tran.Commit();
            }
        }