in MySQL.Data/src/X/Protocol/X/ExprUtil.cs [196:238]
public static Expr ArgObjectToExpr(System.Object value, Boolean allowRelationalColumns, Boolean evaluateStringExpresssion = true)
{
if (value == null)
return BuildLiteralNullScalar();
if (value is Dictionary<string, object>)
value = new XDevAPI.DbDoc(value).ToString();
if (value is XDevAPI.MySqlExpression)
value = (value as XDevAPI.MySqlExpression).value;
if (value is bool)
return BuildLiteralScalar(Convert.ToBoolean(value));
else if (value is byte || value is short || value is int || value is long)
return BuildLiteralScalar(Convert.ToInt64(value));
else if (value is ushort || value is uint || value is ulong)
return BuildLiteralScalar(Convert.ToUInt64(value));
else if (value is float || value is double)
return BuildLiteralScalar(Convert.ToDouble(value));
else if (value is string)
{
try
{
// try to parse expressions
var stringValue = (string) value;
if (!evaluateStringExpresssion) return BuildLiteralScalar((string)value);
Expr expr = new ExprParser(stringValue).Parse();
if (expr.Identifier != null)
return BuildLiteralScalar(stringValue);
return expr;
}
catch
{
// if can't parse, returns as literal
return BuildLiteralScalar((string)value);
}
}
else if (value is XDevAPI.DbDoc)
return (BuildLiteralScalar(value.ToString()));
throw new NotSupportedException("Value of type " + value.GetType() + " is not currently supported.");
}