网上搜的 对应关系 SqlServer CodeSmith bigint Int64 binary Binary bit Boolean char AnsiStringFixedLength datetime DateTime decimal Decimal float Double image Binary int Int32 money Currency nchar StringFixedLength ntext String numeric Decimal nvarchar String real Single smalldatetime DateTime smallint Int16 smallmoney Currency sql_variant Object text AnsiString timestamp Binary tinyint Byte uniqueidentifier Guid varbinary Binary varchar AnsiString
<script runat="template"> private string CreateColumnType(ColumnSchema cs) { string backtye=""; if(cs.AllowDBNull) { backtye= "?"; } switch(cs.DataType) { case DbType.AnsiString: case DbType.String: return "string"; case DbType.Binary: return "byte[]"; case DbType.Boolean: return "bool"+backtye; case DbType.Date: case DbType.DateTime: case DbType.Time: return "DateTime"+backtye; case DbType.Byte: case DbType.Int16: case DbType.Int32: case DbType.Int64: case DbType.UInt16: case DbType.UInt32: case DbType.UInt64: return "int"+backtye; case DbType.Currency: case DbType.VarNumeric: case DbType.Decimal: return "decimal"+backtye; case DbType.Double: return "double"+backtye; case DbType.Guid: return "Guid"+backtye; default: return "object"; } } </script>