示例#1
0
        private static string GetDefaultValueAsString(object value)
        {
            if (value is SpecialDefaultValue)
            {
                switch ((SpecialDefaultValue)value)
                {
                case SpecialDefaultValue.CurrentDateTime:
                    return("GETDATE()");

                default:
                    throw new ArgumentOutOfRangeException("value");
                }
            }
            else if (value is DateTime)
            {
                return(SqlScriptingHelper.ToSql(value, DbType.DateTime));
            }
            else if (value is string)
            {
                return(SqlScriptingHelper.ToSql(value, DbType.String));
            }
            return(System.Convert.ToString(value, CultureInfo.InvariantCulture));
        }
示例#2
0
 public void TestWrappingOfFormatExceptions()
 {
     Assert.That(() => SqlScriptingHelper.ToSql("0", DbType.Boolean, false), Throws.TypeOf <InvalidOperationException>().With.Message.EqualTo("Could not convert '0' of type System.String to a SQL expression of type Boolean."));
 }
示例#3
0
        public void TestWrappingOfFormatExceptions()
        {
            string sql = SqlScriptingHelper.ToSql("0", DbType.Boolean, false);

            Assert.IsNull(sql); // we should never reach this point
        }