Example #1
0
        static void testBlog2()
        {
            try
            {
                var db = new DB();

                var blogs = db.Blogs2;
                foreach (var p in blogs)
                {
                    if (p != null)
                    {
                        Console.WriteLine(string.Format("id {0}", p.ID));
                    }
                }

                var pet = new Blog2
                {
                    ID = (int)DateTime.Now.Ticks
                    ,
                    Name = "blog" + DateTime.Now.Ticks.ToString()
                    ,
                    ssn = 99
                };
                db.Blogs2.Add(pet);
                db.SaveChanges();

                Console.Out.WriteLine("------------ after insert");
                blogs = db.Blogs2;
                foreach (var p in blogs)
                {
                    if (p != null)
                    {
                        Console.WriteLine(string.Format("id {0} name {1}", p.ID, p.Name));
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("*** got exception ***");
            }
            Console.Read();
        }
Example #2
0
        private static void TestPets()
        {
            try
            {
                var db = new DB();

                var pets = db.Blogs2;
                foreach (var p in pets)
                {
                    if (p != null)
                    {
                        Console.WriteLine(string.Format("id {0}", p.ID));
                    }
                    //Console.WriteLine(string.Format("id {0}, name {1}", p.ID, p.Name));
                }

                var pet = new Blog2
                {
                    ID = (int)DateTime.Now.Ticks
                    ,
                    Name = "blog" + DateTime.Now.Ticks.ToString()
                    ,
                    ssn = 99
                };
                db.Blogs2.Add(pet);
                db.SaveChanges();

                Console.WriteLine("** afer insert");
                pets = db.Blogs2;
                foreach (var p in pets)
                {
                    if (p != null)
                    {
                        Console.WriteLine(string.Format("id {0}", p.ID));
                    }
                    //Console.WriteLine(string.Format("id {0}, name {1}", p.ID, p.Name));
                }
            }
            catch (Exception e)
            {
            }
        }