Esempio n. 1
0
        public void LINQTestDML()
        {
            if (context.Connection.State != ConnectionState.Open)
            {
                context.Connection.Open();
            }
            DbTransaction tx = context.Connection.BeginTransaction();

            try
            {
                int initCount = context.HOCKEY.Count();
                int maxID     = (from player in context.HOCKEY
                                 select player.ID).Max();
                HOCKEY newPlayer = new HOCKEY()
                {
                    NAME = "Unknown"
                };
                context.HOCKEY.AddObject(newPlayer);
                context.SaveChanges();
                int afterCount = context.HOCKEY.Count();
                Assert.IsTrue(afterCount == initCount + 1);
                Assert.IsNotNull(newPlayer.ID);
                Assert.IsTrue(newPlayer.ID > maxID);
                context.DeleteObject(newPlayer);
                context.SaveChanges();
                int endCount = context.HOCKEY.Count();

                Assert.AreEqual(initCount, endCount);
            }
            finally
            {
                tx.Rollback();
                context.Connection.Close();
            }
        }
        /// <summary>
        /// Create a new HOCKEY object.
        /// </summary>
        /// <param name="id">Initial value of the ID property.</param>
        public static HOCKEY CreateHOCKEY(global::System.Int32 id)
        {
            HOCKEY hOCKEY = new HOCKEY();

            hOCKEY.ID = id;
            return(hOCKEY);
        }
Esempio n. 3
0
        public void LINQTestDML()
        {
            if (context.Connection.State != ConnectionState.Open)
            {
                context.Connection.Open();
            }
            DbTransaction tx = context.Connection.BeginTransaction();
            try
            {
                int initCount = context.HOCKEY.Count();
                int maxID = (from player in context.HOCKEY
                                select player.ID).Max();
                HOCKEY newPlayer = new HOCKEY() { NAME = "Unknown" };
                context.HOCKEY.AddObject(newPlayer);
                context.SaveChanges();
                int afterCount = context.HOCKEY.Count();
                Assert.IsTrue(afterCount == initCount + 1);
                Assert.IsNotNull(newPlayer.ID);
                Assert.IsTrue(newPlayer.ID > maxID);
                context.DeleteObject(newPlayer);
                context.SaveChanges();
                int endCount = context.HOCKEY.Count();

                Assert.AreEqual(initCount, endCount);
            }
            finally
            {
                tx.Rollback();
                context.Connection.Close();
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the HOCKEY EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToHOCKEY(HOCKEY hOCKEY)
 {
     base.AddObject("HOCKEY", hOCKEY);
 }
Esempio n. 5
0
 /// <summary>
 /// Create a new HOCKEY object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static HOCKEY CreateHOCKEY(global::System.Int32 id)
 {
     HOCKEY hOCKEY = new HOCKEY();
     hOCKEY.ID = id;
     return hOCKEY;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the HOCKEY EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToHOCKEY(HOCKEY hOCKEY)
 {
     base.AddObject("HOCKEY", hOCKEY);
 }