SELECT ‘private ‘ +

CASE data_type

WHEN ‘int’ THEN ‘int’

WHEN ‘bigint’ THEN ‘long’

WHEN ‘binary’ THEN ‘byte[]’

WHEN ‘bit’ THEN ‘bool’

WHEN ‘char’ THEN ‘string’

WHEN ‘date’ THEN ‘DateTime’

WHEN ‘datetime’ THEN ‘DateTime’

WHEN ‘datetime2’ THEN ‘DateTime’

WHEN ‘datetimeoffset’ THEN ‘DateTimeOffset’

WHEN ‘decimal’ THEN ‘decimal’

WHEN ‘float’ THEN ‘float’

WHEN ‘image’ THEN ‘byte[]’

 

WHEN ‘money’ THEN ‘decimal’

WHEN ‘nchar’ THEN ‘string’

WHEN ‘ntext’ THEN ‘string’

WHEN ‘numeric’ THEN ‘decimal’

WHEN ‘nvarchar’ THEN ‘string’

WHEN ‘real’ THEN ‘double’

WHEN ‘smalldatetime’ THEN ‘DateTime’

WHEN ‘smallint’ THEN ‘short’

WHEN ‘smallmoney’ THEN ‘decimal’

WHEN ‘text’ THEN ‘string’

WHEN ‘time’ THEN ‘TimeSpan’

WHEN ‘timestamp’ THEN ‘DateTime’

WHEN ‘tinyint’ THEN ‘int’

WHEN ‘uniqueidentifier’ THEN ‘Guid’

WHEN ‘varbinary’ THEN ‘byte[]’

WHEN ‘varchar’ THEN ‘string’

WHEN ‘nchar’ THEN ‘string’

ELSE ‘CHECK THIS.. ‘ + data_type + ‘ DataType’

END + ‘ ‘+’_’+Lower(COLUMN_NAME) + ‘;’

 

FROM information_schema.columns

WHERE table_name = ‘Your Table Name

 

union all

 

SELECT ‘public virtual ‘ +

CASE data_type

WHEN ‘int’ THEN ‘int’

WHEN ‘bigint’ THEN ‘long’

WHEN ‘binary’ THEN ‘byte[]’

WHEN ‘bit’ THEN ‘bool’

WHEN ‘char’ THEN ‘string’

WHEN ‘date’ THEN ‘DateTime’

WHEN ‘datetime’ THEN ‘DateTime’

WHEN ‘datetime2’ THEN ‘DateTime’

WHEN ‘datetimeoffset’ THEN ‘DateTimeOffset’

WHEN ‘decimal’ THEN ‘decimal’

WHEN ‘float’ THEN ‘float’

WHEN ‘image’ THEN ‘byte[]’

 

WHEN ‘money’ THEN ‘decimal’

WHEN ‘nchar’ THEN ‘string’

WHEN ‘ntext’ THEN ‘string’

WHEN ‘numeric’ THEN ‘decimal’

WHEN ‘nvarchar’ THEN ‘string’

WHEN ‘real’ THEN ‘double’

WHEN ‘smalldatetime’ THEN ‘DateTime’

WHEN ‘smallint’ THEN ‘short’

WHEN ‘smallmoney’ THEN ‘decimal’

WHEN ‘text’ THEN ‘string’

WHEN ‘time’ THEN ‘TimeSpan’

WHEN ‘timestamp’ THEN ‘DateTime’

WHEN ‘tinyint’ THEN ‘int’

WHEN ‘uniqueidentifier’ THEN ‘Guid’

WHEN ‘varbinary’ THEN ‘byte[]’

WHEN ‘varchar’ THEN ‘string’

WHEN ‘nchar’ THEN ‘string’

ELSE ‘CHECK THIS.. ‘ + data_type + ‘ DataType’

END + ‘ ‘ + COLUMN_NAME + char(13)+

‘{

get { return ‘+ ‘_’+ LOWER(COLUMN_NAME)+’; }

set { ‘+’_’+LOWER(COLUMN_NAME)+’ = value; }

}’

 

FROM information_schema.columns

WHERE table_name = ‘Your Table Name