Some more type checking on QueryScalar
This commit is contained in:
parent
29170e62a6
commit
ce2873fa81
1 changed files with 5 additions and 2 deletions
|
|
@ -100,9 +100,12 @@ namespace TShockAPI.DB
|
|||
com.AddParameter("@" + i, args[i]);
|
||||
|
||||
object output = com.ExecuteScalar();
|
||||
if (typeof(IConvertible).IsAssignableFrom(output.GetType()))
|
||||
if (output.GetType() != typeof(T))
|
||||
{
|
||||
return (T)Convert.ChangeType(output, typeof(T));
|
||||
if (typeof(IConvertible).IsAssignableFrom(output.GetType()))
|
||||
{
|
||||
return (T)Convert.ChangeType(output, typeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
return (T)output;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue