本文整理汇总了C#中SqlDataType类的典型用法代码示例。如果您正苦于以下问题:C# SqlDataType类的具体用法?C# SqlDataType怎么用?C# SqlDataType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlDataType类属于命名空间,在下文中一共展示了SqlDataType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:donners77,项目名称:linq2db,代码行数:31,代码来源:MySqlSqlBuilder.cs
示例2: Build
public TSqlDataType Build(SqlDataType value)
{
return new TSqlDataType()
{
SqlDataType = value,
};
}
开发者ID:Seddryck,项目名称:Tibre,代码行数:7,代码来源:TSqlDataTypeFactory.cs
示例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;
}
开发者ID:zerazobz,项目名称:AdoTemplateGenerator,代码行数:29,代码来源:Program.cs
示例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
};
}
开发者ID:s-amani,项目名称:iDbGenerator,代码行数:60,代码来源:DataType.cs
示例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;
}
}
开发者ID:donners77,项目名称:linq2db,代码行数:8,代码来源:SybaseSqlBuilder.cs
示例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;
}
}
开发者ID:henleygao,项目名称:linq2db,代码行数:11,代码来源:SqlServer2000SqlProvider.cs
示例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);
}
开发者ID:codeinsiders,项目名称:sharpql,代码行数:11,代码来源:Sql.cs
示例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;
}
开发者ID:codeinsiders,项目名称:sharpql,代码行数:11,代码来源:CastFunction.cs
示例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;
}
开发者ID:codeinsiders,项目名称:sharpql,代码行数:12,代码来源:ConvertFunction.cs
示例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);
}
开发者ID:codeinsiders,项目名称:sharpql,代码行数:12,代码来源:Sql.cs
示例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;
}
}
开发者ID:donners77,项目名称:linq2db,代码行数:12,代码来源:InformixSqlBuilder.cs
示例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;
}
}
开发者ID:Convey-Compliance,项目名称:linq2db,代码行数:14,代码来源:SqlCeSqlBuilder.cs
示例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);
}
开发者ID:Convey-Compliance,项目名称:linq2db,代码行数:45,代码来源:SapHanaSqlBuilder.cs
示例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);
}
开发者ID:Convey-Compliance,项目名称:linq2db,代码行数:18,代码来源:SqlCeMappingSchema.cs
示例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;
}
}
开发者ID:donners77,项目名称:linq2db,代码行数:42,代码来源:SapHanaOdbcSqlBuilder.cs
示例16: BuildDataType
protected override void BuildDataType(SqlDataType type, bool createDbType = false)
{
switch (type.DataType)
{
case DataType.Decimal :
base.BuildDataType(type.Precision > 18 ? new SqlDataType(type.DataType, type.Type, null, 18, type.Scale) : type);
break;
case DataType.SByte :
case DataType.Byte : StringBuilder.Append("SmallInt"); break;
case DataType.Money : StringBuilder.Append("Decimal(18,4)"); break;
case DataType.SmallMoney : StringBuilder.Append("Decimal(10,4)"); break;
case DataType.DateTime2 :
case DataType.SmallDateTime :
case DataType.DateTime : StringBuilder.Append("TimeStamp"); break;
case DataType.NVarChar :
StringBuilder.Append("VarChar");
if (type.Length > 0)
StringBuilder.Append('(').Append(type.Length).Append(')');
StringBuilder.Append(" CHARACTER SET UNICODE_FSS");
break;
default : base.BuildDataType(type); break;
}
}
开发者ID:donners77,项目名称:linq2db,代码行数:23,代码来源:FirebirdSqlBuilder.cs
示例17: BuildDataType
protected override void BuildDataType(SqlDataType type, bool createDbType = false)
{
switch (type.DataType)
{
case DataType.DateTimeOffset :
case DataType.DateTime2 :
case DataType.Time :
case DataType.Date : StringBuilder.Append("DateTime"); return;
case DataType.Xml : StringBuilder.Append("NText"); return;
case DataType.NVarChar :
if (type.Length == int.MaxValue || type.Length < 0)
{
StringBuilder
.Append(type.DataType)
.Append("(4000)");
return;
}
break;
case DataType.VarChar :
case DataType.VarBinary :
if (type.Length == int.MaxValue || type.Length < 0)
{
StringBuilder
.Append(type.DataType)
.Append("(8000)");
return;
}
break;
}
base.BuildDataType(type, createDbType);
}
开发者ID:donners77,项目名称:linq2db,代码行数:37,代码来源:SqlServer2000SqlBuilder.cs
示例18: BuildDataType
protected override void BuildDataType(SqlDataType type, bool createDbType = false)
{
switch (type.DataType)
{
case DataType.SByte :
case DataType.Byte : StringBuilder.Append("SmallInt"); 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 :
case DataType.DateTime : StringBuilder.Append("TimeStamp"); break;
case DataType.Boolean : StringBuilder.Append("Boolean"); break;
case DataType.NVarChar :
StringBuilder.Append("VarChar");
if (type.Length > 0)
StringBuilder.Append('(').Append(type.Length).Append(')');
break;
case DataType.Undefined :
if (type.Type == typeof(string))
goto case DataType.NVarChar;
break;
default : base.BuildDataType(type); break;
}
}
开发者ID:donners77,项目名称:linq2db,代码行数:24,代码来源:PostgreSQLSqlBuilder.cs
示例19: BuildDataType
protected override void BuildDataType(StringBuilder sb, SqlDataType type)
{
switch (type.SqlDbType)
{
#if !MONO
case SqlDbType.DateTime2 : sb.Append("DateTime"); break;
#endif
default : base.BuildDataType(sb, type); break;
}
}
开发者ID:henleygao,项目名称:linq2db,代码行数:10,代码来源:SybaseSqlProvider.cs
示例20: Constant
public static SqlExpression Constant(SqlDataType dataType, object val)
{
SqlExpression expression = new SqlExpression();
expression.val = new SqlConstant(dataType, val);
expression.type = SqlExpressionType.Constant;
return expression;
}
开发者ID:vanloc0301,项目名称:mychongchong,代码行数:7,代码来源:SqlExpression.cs
注:本文中的SqlDataType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论