Example #1
0
        /// <summary>
        /// 测试直接执行 SQL 语句.
        /// </summary>
        private static void ExecuteCommandTest()
        {
            

            Test context = new Test(connString);


            Console.WriteLine("手动执行 SQL : INSERT INTO TestMain(id, value) VALUES (4, 'FOUR') ");
            int r1 = context.ExecuteCommand("INSERT INTO TestMain(id, value) VALUES (4, 'FOUR') ");
            Console.WriteLine("执行结果:{0}", r1);



            Console.WriteLine("手动执行 SQL : SELECT * FROM TestMain WHERE id = 4 ");
            var mainData = context.ExecuteQuery<TestMain>("SELECT * FROM TestMain WHERE id = 4");
            foreach (TestMain data in mainData)
            {
                Console.WriteLine("Main[{0}, {1}]", data.Id, data.Value);
            }


            Console.WriteLine("手动执行 SQL : DELETE TestMain WHERE  id = 4");
            int r2 = context.ExecuteCommand("DELETE TestMain WHERE  id = 4");
            Console.WriteLine("执行结果:{0}", r2);
        }
Example #2
0
        /// <summary>
        /// 测试直接执行 SQL 语句.
        /// </summary>
        private static void ExecuteQueryTest()
        {
            Test context = new Test(connString);

            Console.WriteLine("手动执行 SQL : SELECT * FROM test_main WHERE id = 2 ");
            var mainData = context.ExecuteQuery<TestMain>("SELECT * FROM TestMain WHERE id = 2");

            foreach (TestMain data in mainData)
            {
                Console.WriteLine("Main[{0}, {1}]", data.Id, data.Value);
            }
        }