本文整理汇总了C#中SqlDataType类的典型用法代码示例。如果您正苦于以下问题:C# SqlDataType类的具体用法?C# SqlDataType怎么用?C# SqlDataType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlDataType类属于命名空间,在下文中一共展示了SqlDataType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildDataType
protected override void BuildDataType(SqlDataType type, bool createDbType = false)
{
switch (type.DataType)
{
case DataType.Int32 :
case DataType.UInt16 :
case DataType.Int16 :
if (createDbType) goto default;
StringBuilder.Append("Signed");
break;
case DataType.SByte :
case DataType.Byte :
if (createDbType) goto default;
StringBuilder.Append("Unsigned");
break;
case DataType.Money : StringBuilder.Append("Decimal(19,4)"); break;
case DataType.SmallMoney : StringBuilder.Append("Decimal(10,4)"); break;
case DataType.DateTime2 :
case DataType.SmallDateTime : StringBuilder.Append("DateTime"); break;
case DataType.Boolean : StringBuilder.Append("Boolean"); break;
case DataType.Double :
case DataType.Single : base.BuildDataType(SqlDataType.Decimal); break;
case DataType.VarChar :
case DataType.NVarChar :
StringBuilder.Append("Char");
if (type.Length > 0)
StringBuilder.Append('(').Append(type.Length).Append(')');
break;
default : base.BuildDataType(type); break;
}
}
示例2: Build
public TSqlDataType Build(SqlDataType value)
{
return new TSqlDataType()
{
SqlDataType = value,
};
}
示例3: ConvertSqlTypeEnum
private static SqlDbType ConvertSqlTypeEnum(SqlDataType sqlDataType)
{
SqlDbType sqlDbType;
switch (sqlDataType)
{
case SqlDataType.UserDefinedType:
sqlDbType = System.Data.SqlDbType.Udt;
break;
case SqlDataType.None:
case SqlDataType.NVarCharMax:
case SqlDataType.UserDefinedDataType:
case SqlDataType.VarBinaryMax:
case SqlDataType.VarCharMax:
case SqlDataType.SysName:
//case SqlDataType.Numeric:
case SqlDataType.UserDefinedTableType:
case SqlDataType.HierarchyId:
case SqlDataType.Geometry:
case SqlDataType.Geography:
throw new NotSupportedException("Unable to convert to SqlDbType:" + sqlDataType);
case SqlDataType.Numeric:
sqlDbType = SqlDbType.Decimal;
break;
default:
sqlDbType = (SqlDbType)Enum.Parse(typeof(SqlDbType), sqlDataType.ToString());
break;
}
return sqlDbType;
}
示例4: ConvertToDotNetType
public static DataType ConvertToDotNetType(SqlDataType dbDataType)
{
string name = "string";
switch (dbDataType) {
case SqlDataType.XML:
case SqlDataType.VARCHAR:
case SqlDataType.NVARCHAR:
case SqlDataType.CHAR:
case SqlDataType.NCHAR:
case SqlDataType.NTEXT:
case SqlDataType.TEXT:
name = "string";
break;
case SqlDataType.BIGINT:
name = "long";
break;
case SqlDataType.TIMESTAMP:
case SqlDataType.BINARY:
case SqlDataType.IMAGE:
case SqlDataType.VARBINARY:
name = "byte[]";
break;
case SqlDataType.MONEY:
case SqlDataType.BIT:
name = "bool";
break;
case SqlDataType.DATETIME:
name = "DateTime";
break;
case SqlDataType.REAL:
case SqlDataType.DECIMAL:
name = "decimal";
break;
case SqlDataType.FLOAT:
name = "single";
break;
case SqlDataType.SMALLMONEY:
case SqlDataType.INT:
name = "int";
break;
case SqlDataType.SMALLDATETIME:
break;
case SqlDataType.SMALLINT:
name = "short";
break;
case SqlDataType.SQL_VARIANT:
break;
case SqlDataType.TINYINT:
name = "byte";
break;
case SqlDataType.UNIQUEIDENTIFIER:
name = "GUID";
break;
default:
throw new ArgumentOutOfRangeException("dbDataType");
}
return new DataType {
Name = name
};
}
示例5: BuildDataType
protected override void BuildDataType(SqlDataType type, bool createDbType = false)
{
switch (type.DataType)
{
case DataType.DateTime2 : StringBuilder.Append("DateTime"); break;
default : base.BuildDataType(type); break;
}
}
示例6: BuildDataType
protected override void BuildDataType(StringBuilder sb, SqlDataType type)
{
switch (type.SqlDbType)
{
case SqlDbType.DateTimeOffset :
case SqlDbType.DateTime2 :
case SqlDbType.Time :
case SqlDbType.Date : sb.Append("DateTime"); break;
default : base.BuildDataType(sb, type); break;
}
}
示例7: Cast
public static Function Cast(Expression exp, SqlDataType type)
{
if (exp == null) {
throw new ArgumentNullException("exp");
}
if (type == null) {
throw new ArgumentNullException("type");
}
return new CastFunction(exp, type);
}
示例8: CastFunction
public CastFunction(Expression exp, SqlDataType type)
{
if (exp == null) {
throw new ArgumentNullException("exp");
}
if (type == null) {
throw new ArgumentNullException("type");
}
this.Expression = exp;
this.Type = type;
}
示例9: ConvertFunction
public ConvertFunction(SqlDataType type, Expression exp, uint? style)
{
if (type == null) {
throw new ArgumentNullException("type");
}
if (exp == null) {
throw new ArgumentNullException("exp");
}
this.Type = type;
this.Value = exp;
this.Style = style;
}
示例10: Convert
public static Function Convert(SqlDataType type, Expression exp, uint? style = null)
{
if (type == null) {
throw new ArgumentNullException("type");
}
if (exp == null) {
throw new ArgumentNullException("exp");
}
return new ConvertFunction(type, exp, style);
}
示例11: BuildDataType
protected override void BuildDataType(SqlDataType type, bool createDbType = false)
{
switch (type.DataType)
{
case DataType.DateTime : StringBuilder.Append("datetime year to second"); break;
case DataType.DateTime2 : StringBuilder.Append("datetime year to fraction"); break;
case DataType.SByte :
case DataType.Byte : StringBuilder.Append("SmallInt"); break;
case DataType.SmallMoney : StringBuilder.Append("Decimal(10,4)"); break;
default : base.BuildDataType(type); break;
}
}
示例12: BuildDataType
protected override void BuildDataType(SqlDataType type, bool createDbType = false)
{
switch (type.DataType)
{
case DataType.Char : base.BuildDataType(new SqlDataType(DataType.NChar, type.Length)); break;
case DataType.VarChar : base.BuildDataType(new SqlDataType(DataType.NVarChar, type.Length)); break;
case DataType.SmallMoney : StringBuilder.Append("Decimal(10,4)"); break;
case DataType.DateTime2 :
case DataType.Time :
case DataType.Date :
case DataType.SmallDateTime : StringBuilder.Append("DateTime"); break;
default : base.BuildDataType(type); break;
}
}
示例13: BuildDataType
protected override void BuildDataType(SqlDataType type, bool createDbType = false)
{
switch (type.DataType)
{
case DataType.Int32 :
case DataType.UInt16 :
StringBuilder.Append("Integer");
return;
case DataType.Double:
StringBuilder.Append("Double");
return;
case DataType.DateTime2 :
case DataType.DateTime :
case DataType.Time:
StringBuilder.Append("Timestamp");
return;
case DataType.SmallDateTime :
StringBuilder.Append("SecondDate");
return;
case DataType.Boolean :
StringBuilder.Append("TinyInt");
return;
case DataType.Image:
StringBuilder.Append("Blob");
return;
case DataType.Xml:
StringBuilder.Append("Clob");
return;
case DataType.Guid:
StringBuilder.Append("Char (36)");
return;
case DataType.NVarChar:
case DataType.VarChar:
case DataType.VarBinary:
if (type.Length == int.MaxValue || type.Length < 0)
{
StringBuilder
.Append(type.DataType)
.Append("(Max)");
return;
}
break;
}
base.BuildDataType(type, createDbType);
}
示例14: ConvertCharToSql
static void ConvertCharToSql(StringBuilder stringBuilder, SqlDataType sqlDataType, char value)
{
string start;
switch (sqlDataType.DataType)
{
case DataType.Char :
case DataType.VarChar :
case DataType.Text :
start = "'";
break;
default :
start = "N'";
break;
}
DataTools.ConvertCharToSql(stringBuilder, start, AppendConversion, value);
}
示例15: BuildDataType
protected override void BuildDataType(SqlDataType type, bool createDbType = false)
{
switch (type.DataType)
{
case DataType.Int32 :
case DataType.UInt16 :
StringBuilder.Append("Integer");
break;
case DataType.Double:
StringBuilder.Append("Double");
break;
case DataType.Money :
StringBuilder.Append("Decimal(19,4)");
break;
case DataType.SmallMoney :
StringBuilder.Append("Decimal(10,4)");
break;
case DataType.DateTime2 :
case DataType.DateTime :
case DataType.Time:
StringBuilder.Append("Timestamp");
break;
case DataType.SmallDateTime :
StringBuilder.Append("SecondDate");
break;
case DataType.Boolean :
StringBuilder.Append("TinyInt");
break;
case DataType.Image:
StringBuilder.Append("Blob");
break;
case DataType.Xml:
StringBuilder.Append("Clob");
break;
case DataType.Guid:
StringBuilder.Append("Char (36)");
break;
default:
base.BuildDataType(type, createDbType);
break;
}
}