SPToCore
SPToCore copied to clipboard
adding types timestamps and image
private static string SP_GetType(string type, bool isNullable)
{
type = type.ToLower().Trim();
if (type == "int")
return "int" + (isNullable ? "?" : "");
else if (type.Contains("numeric"))
return "decimal" + (isNullable ? "?" : "");
else if (type == "bigint")
return "Int64" + (isNullable ? "?" : "");
else if (type == "smallint")
return "int" + (isNullable ? "?" : "");
else if (type == "tinyint")
return "Byte" + (isNullable ? "?" : "");
else if (type == "bigint")
return "Int64" + (isNullable ? "?" : "");
else if (type.IndexOf("decimal") > -1)
return "decimal" + (isNullable ? "?" : "");
else if (type.IndexOf("nvarchar") > -1)
return "string";
else if (type.IndexOf("varchar") > -1)
return "string";
else if (type.IndexOf("char") > -1)
return "string";
else if (type.IndexOf("smalldatetime") > -1)
return "DateTime" + (isNullable ? "?" : "");
else if (type.IndexOf("datetimeoffset") > -1)
return "DateTimeOffset" + (isNullable ? "?" : "");
else if (type.IndexOf("datetime") > -1)
return "DateTime" + (isNullable ? "?" : "");
else if (type.IndexOf("date") > -1)
return "DateTime" + (isNullable ? "?" : "");
else if (type == "decimal")
return "decimal" + (isNullable ? "?" : "");
else if (type == "bit")
return "bool" + (isNullable ? "?" : "");
else if (type == "uniqueidentifier")
return "Guid" + (isNullable ? "?" : "");
else if (type == "xml")
return "string";
else if (type == "timestamp")
return "byte[]"; // Manejar el tipo "timestamp"
else if (type == "timestamp(max)")
return "byte[]"; // Manejar el tipo "timestamp"
else if (type == "varbinary(max)") // Manejar el tipo "varbinary(max)"
return "byte[]"; // Mapearlo a un arreglo de bytes
else if (type == "varbinary") // Manejar el tipo "varbinary(max)"
return "byte[]"; // Mapearlo a un arreglo de bytes
else
throw new UnknownDBTypeException(type);
}
private static string SP_GetDbType(string type)
{
type = type.ToLower().Trim();
if (type == "int")
return "Int32";
else if (type == "bigint")
return "Int64";
else if (type.Contains("numeric"))
return "Decimal";
else if (type == "smallint")
return "Int16";
else if (type == "tinyint")
return "Byte";
else if (type == "bigint")
return "Int64";
else if (type.IndexOf("decimal") > -1)
return "Decimal";
else if (type.IndexOf("nvarchar") > -1)
return "String";
else if (type.IndexOf("varchar") > -1)
return "String";
else if (type.IndexOf("char") > -1)
return "String";
else if (type.IndexOf("smalldatetime") > -1)
return "DateTime";
else if (type.IndexOf("datetimeoffset") > -1)
return "DateTime";
else if (type.IndexOf("datetime") > -1)
return "DateTime";
else if (type.IndexOf("date") > -1)
return "DateTime";
else if (type == "bit")
return "Boolean";
else if (type == "uniqueidentifier")
return "Guid";
else if (type == "xml")
return "Xml";
else if (type == "timestamp")
return "byte[]"; // Manejar el tipo "timestamp"
else if (type == "timestamp(max)")
return "byte[]"; // Manejar el tipo "timestamp"
else if (type == "varbinary(max)") // Manejar el tipo "varbinary(max)"
return "byte[]"; // Mapearlo a un arreglo de bytes
else if (type == "varbinary") // Manejar el tipo "varbinary(max)"
return "byte[]"; // Mapearlo a un arreglo de bytes
else
throw new UnknownDBTypeException(type);
}