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)); }
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.")); }
public void TestWrappingOfFormatExceptions() { string sql = SqlScriptingHelper.ToSql("0", DbType.Boolean, false); Assert.IsNull(sql); // we should never reach this point }