CodeSmith模板编写中,数据类型由DbType转化为C#类型(函数)

public string DataType2CSharpType(System.Data.DbType dbType) 
 
    { 
 
        switch (dbType) 
 
        { 
 
            case DbType.AnsiString: 
 
                return "string"; 
 
            case DbType.AnsiStringFixedLength: 
 
                return "string"; 
 
            case DbType.Binary: 
 
                return "byte[]"; 
 
            case DbType.Boolean: 
 
                return "bool"; 
 
            case DbType.Byte: 
 
                return "byte"; 
 
            case DbType.Currency: 
 
                return "decimal"; 
 
            case DbType.Date: 
 
                return "DateTime"; 
 
            case DbType.DateTime: 
 
                return "DateTime"; 
 
            case DbType.DateTime2: 
 
                return "DateTime"; 
 
            case DbType.DateTimeOffset: 
 
                return "DateTime"; 
 
            case DbType.Decimal: 
 
                return "decimal"; 
 
            case DbType.Double: 
 
                return "double"; 
 
            case DbType.Guid: 
 
                return "Guid"; 
 
            case DbType.Int16: 
 
                return "short"; 
 
            case DbType.Int32: 
 
                return "int"; 
 
            case DbType.Int64: 
 
                return "long"; 
 
            case DbType.Object: 
 
                return "object"; 
 
            case DbType.SByte: 
 
                return "sbyte"; 
 
            case DbType.Single: 
 
                return "float"; 
 
            case DbType.String: 
 
                return "string"; 
 
            case DbType.StringFixedLength: 
 
                return "string"; 
 
            case DbType.Time: 
 
                return "DateTime"; 
 
                
 
            case DbType.UInt16: 
 
                return "ushort"; 
 
            case DbType.UInt32: 
 
                return "uint"; 
 
            case DbType.UInt64: 
 
                return "ulong"; 
 
            case DbType.VarNumeric: 
 
                return "decimal"; 
 
            case DbType.Xml: 
 
                return "string"; 
 
            default: 
 
                return "object"; 
 
        } 
 
    } 

转载于:https://www.cnblogs.com/T_max_Csharp/archive/2011/03/18/1987606.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值