protected static string GetSqlType(PropertyInfo info)
{
string type = String.Empty;
switch (info.PropertyType.Name.ToLower())
{
case "int":
case "int16":
case "int32": type = "int"; break;
case "int64": type = "bigint"; break;
case "single":
case "double": type = "money"; break;
case "datetime": type = "datetime"; break;
case "bool":
case "boolean": type = "bit"; break;
default: type = "[nvarchar] (100)"; break;
}
return type;
}
protected static DbType GetDbType(PropertyInfo info)
{
DbType type = DbType.String;
switch (info.PropertyType.Name.ToLower())
{
case "int":
case "int16":
case "int32": type = DbType.Int32; break;
case "int64": type = DbType.Int64; break;
case "single":
case "double": type =DbType.Double; break;
case "datetime": type = DbType.DateTime2; break;
case "bool":
case "boolean": type = DbType.Binary; break;
default: type = DbType.String; break;
}
return type;
}
{
string type = String.Empty;
switch (info.PropertyType.Name.ToLower())
{
case "int":
case "int16":
case "int32": type = "int"; break;
case "int64": type = "bigint"; break;
case "single":
case "double": type = "money"; break;
case "datetime": type = "datetime"; break;
case "bool":
case "boolean": type = "bit"; break;
default: type = "[nvarchar] (100)"; break;
}
return type;
}
protected static DbType GetDbType(PropertyInfo info)
{
DbType type = DbType.String;
switch (info.PropertyType.Name.ToLower())
{
case "int":
case "int16":
case "int32": type = DbType.Int32; break;
case "int64": type = DbType.Int64; break;
case "single":
case "double": type =DbType.Double; break;
case "datetime": type = DbType.DateTime2; break;
case "bool":
case "boolean": type = DbType.Binary; break;
default: type = DbType.String; break;
}
return type;
}

浙公网安备 33010602011771号