예제 #1
0
        /// <summary>
        /// 测试 Identity 的处理.
        /// </summary>
        private static void TestIdeneity()
        {
            Console.WriteLine("===== 测试父子关系表的 Identity 的处理.");

            using (Test context = new Test(connString))
            {
                test_Identity_tab testMainData = new test_Identity_tab()
                {
                    value = "测试主"
                };

                test_Identity_tab_Sub testSubData = new test_Identity_tab_Sub()
                {
                    Value = "测试子"
                };

                testSubData.test_Identity_tab = testMainData;


                // 插入.
                context.test_Identity_tab.InsertOnSubmit(testMainData);
                context.test_Identity_tab_Sub.InsertOnSubmit(testSubData);

                Console.WriteLine("Before SubmitChanges testMainData.id = {0}", testMainData.id);
                Console.WriteLine("Before SubmitChanges testSubData.id = {0}", testSubData.Id);

                context.SubmitChanges();

                Console.WriteLine("After SubmitChanges testMainData.id = {0}", testMainData.id);
                Console.WriteLine("After SubmitChanges testSubData.id = {0}", testSubData.Id);
            }
        }
예제 #2
0
        /// <summary>
        /// 测试 Identity 的处理.
        /// </summary>
        private static void TestIdeneity()
        {

            Console.WriteLine("===== 测试父子关系表的 Identity 的处理.");

            using (Test context = new Test(connString))
            {
                test_Identity_tab testMainData = new test_Identity_tab()
                {
                    value = "测试主"
                };

                test_Identity_tab_Sub testSubData = new test_Identity_tab_Sub()
                {
                    Value = "测试子"
                };

                testSubData.test_Identity_tab = testMainData;


                // 插入.
                context.test_Identity_tab.InsertOnSubmit(testMainData);
                context.test_Identity_tab_Sub.InsertOnSubmit(testSubData);

                Console.WriteLine("Before SubmitChanges testMainData.id = {0}", testMainData.id);
                Console.WriteLine("Before SubmitChanges testSubData.id = {0}", testSubData.Id);

                context.SubmitChanges();

                Console.WriteLine("After SubmitChanges testMainData.id = {0}", testMainData.id);
                Console.WriteLine("After SubmitChanges testSubData.id = {0}", testSubData.Id);
            }

        }