/// <summary>
        /// 创建新的 TEST_SUB 对象。
        /// </summary>
        /// <param name="id">ID 属性的初始值。</param>
        public static TEST_SUB CreateTEST_SUB(global::System.Decimal id)
        {
            TEST_SUB tEST_SUB = new TEST_SUB();

            tEST_SUB.ID = id;
            return(tEST_SUB);
        }
示例#2
0
        public bool TestInsertSub(int id, int main_id, string val)
        {
            // 请注意:
            // 由于是使用 WCF 来进行事务的管理.

            try
            {
                using (TestEntities context = new TestEntities())
                {
                    TEST_SUB subData = new TEST_SUB()
                    {
                        ID      = id,
                        MAIN_ID = main_id,
                        VALUE   = val
                    };


                    context.AddToTEST_SUB(subData);

                    context.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                // 由于是使用 WCF 来管理事务.
                // 因此,发生异常了, 就必须抛出异常
                // 不能自己 Catch 住了, 然后简单返回 false.

                // 如果自己 Catch 住了,简单返回 false 的话, WCF 认为你的程序执行正常,就你做的修改提交了,而不是回滚掉。
                throw new FaultException(ex.ToString(), new FaultCode(ex.Message));
            }
        }
示例#3
0
        public bool TestInsertSub(int id, int main_id, string val)
        {
            // 请注意:
            // 由于是使用 WCF 来进行事务的管理.

            try
            {
                using (TestEntities context = new TestEntities())
                {
                    TEST_SUB subData = new TEST_SUB()
                    {
                        ID = id,
                        MAIN_ID = main_id,
                        VALUE = val
                    };

                    context.AddToTEST_SUB(subData);

                    context.SaveChanges();
                }

                return true;
            }
            catch (Exception ex)
            {
                // 由于是使用 WCF 来管理事务.
                // 因此,发生异常了, 就必须抛出异常
                // 不能自己 Catch 住了, 然后简单返回 false.

                // 如果自己 Catch 住了,简单返回 false 的话, WCF 认为你的程序执行正常,就你做的修改提交了,而不是回滚掉。
                throw new FaultException(ex.ToString(), new FaultCode(ex.Message));
            }
        }
 /// <summary>
 /// 创建新的 TEST_SUB 对象。
 /// </summary>
 /// <param name="id">ID 属性的初始值。</param>
 public static TEST_SUB CreateTEST_SUB(global::System.Decimal id)
 {
     TEST_SUB tEST_SUB = new TEST_SUB();
     tEST_SUB.ID = id;
     return tEST_SUB;
 }
 /// <summary>
 /// 用于向 TEST_SUB EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToTEST_SUB(TEST_SUB tEST_SUB)
 {
     base.AddObject("TEST_SUB", tEST_SUB);
 }
 /// <summary>
 /// 用于向 TEST_SUB EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToTEST_SUB(TEST_SUB tEST_SUB)
 {
     base.AddObject("TEST_SUB", tEST_SUB);
 }