Beispiel #1
0
        public void ParameterSpecificationTest()
        {
            SqlParameterizedQueryParser.RegisterParameterSpecification(typeof(int), SqlDbType.Decimal);

            Db.T($"SELECT * FROM Test1 WHERE [Index] = {0}").ExecuteNonQuery();
            var command = (SqlCommand)traceService.Last().CommandObject;

            Assert.AreEqual(command.Parameters[0].SqlDbType, SqlDbType.Decimal, "注册参数规范测试失败");

            SqlParameterizedQueryParser.UnregisterParameterSpecification(typeof(int));

            Db.T($"SELECT * FROM Test1 WHERE [Index] = {0}").ExecuteNonQuery();
            command = (SqlCommand)traceService.Last().CommandObject;
            Assert.AreNotEqual(command.Parameters[0].SqlDbType, SqlDbType.Decimal, "解除注册参数规范测试失败");
        }