Some more type checking on QueryScalar

This commit is contained in:
Chris 2020-11-29 15:18:03 +10:30
parent 29170e62a6
commit ce2873fa81

View file

@ -100,10 +100,13 @@ namespace TShockAPI.DB
com.AddParameter("@" + i, args[i]);
object output = com.ExecuteScalar();
if (output.GetType() != typeof(T))
{
if (typeof(IConvertible).IsAssignableFrom(output.GetType()))
{
return (T)Convert.ChangeType(output, typeof(T));
}
}
return (T)output;
}