convert a Type to DBType ?!

  • Thread starter Thread starter franky
  • Start date Start date
F

franky

For convert a Type to DBType do I need absolutly to proceed with a switch?

switch(var1.GetType().Name.ToString())
{
case("int"): parameter.DbType = (DbType)SqlDbType.Int;
break;
case("string"): parameter.DbType = (DbType)SqlDbType.NVarChar;
break;
case("bool"): parameter.DbType = (DbType)SqlDbType.Bit;
break;
}
 
Back
Top