Script para gerar classe de transporte

SELECT
		'[DataMember, DataColumnAttribute(Label = "' + COLUMN_NAME +  '", ColumnName = "' + COLUMN_NAME +  '", ColumnType = DataColumnType.NormalColumn)]' + CHAR(13)
		+ 'public ' +
		CASE DATA_TYPE
			WHEN 'bigint' THEN ' Nullable<Int64> '
			WHEN 'binary' THEN ' Nullable<> '
			WHEN 'bit' THEN ' Nullable<> '
			WHEN 'char' THEN ' Nullable<Char> '
			WHEN 'date' THEN ' Nullable<DateTime> '
			WHEN 'datetime' THEN ' Nullable<DateTime> '
			WHEN 'datetime2' THEN ' Nullable<DateTime> '
			WHEN 'datetimeoffset' THEN ' Nullable<DateTime> '
			WHEN 'decimal' THEN ' Nullable<Decimal> '
			WHEN 'float' THEN ' Nullable<Decimal> '
			WHEN 'geography' THEN ' Nullable<> '
			WHEN 'geometry' THEN ' Nullable<> '
			WHEN 'hierarchyid' THEN ' Nullable<> '
			WHEN 'image' THEN ' Nullable<> '
			WHEN 'int' THEN ' Nullable<Int32> '
			WHEN 'money' THEN ' Nullable<Decimal> '
			WHEN 'nchar' THEN ' String '
			WHEN 'ntext' THEN ' String '
			WHEN 'numeric' THEN ' Nullable<Decimal> '
			WHEN 'nvarchar' THEN ' String '
			WHEN 'real' THEN ' Decimal '
			WHEN 'smalldatetime' THEN ' Nullable<DateTime> '
			WHEN 'smallint' THEN ' Nullable<Int16> '
			WHEN 'smallmoney' THEN ' Nullable<Decimal> '
			WHEN 'sql_variant' THEN ' Nullable<> '
			WHEN 'sysname' THEN ' Nullable<> '
			WHEN 'text' THEN ' String '
			WHEN 'time' THEN ' Nullable<DateTime> '
			WHEN 'timestamp' THEN ' Nullable<Byte> '
			WHEN 'tinyint' THEN ' Nullable<Int16> '
			WHEN 'uniqueidentifier' THEN ' Nullable<Guid> '
			WHEN 'varbinary' THEN ' Nullable<Byte> '
			WHEN 'varchar' THEN ' String '
			WHEN 'xml' THEN ' String '
		END
		+ REPLACE(COLUMN_NAME,'_','') + ' { get; set; }' + CHAR(13)
FROM
		INFORMATION_SCHEMA.COLUMNS
WHERE
		TABLE_NAME LIKE 'TB_EMAIL'

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *