Skip to content

Instantly share code, notes, and snippets.

@pedroinfo
Last active November 4, 2016 17:40
Show Gist options
  • Save pedroinfo/38a9791c37a2f6dcda118b4c997fe0cf to your computer and use it in GitHub Desktop.
Save pedroinfo/38a9791c37a2f6dcda118b4c997fe0cf to your computer and use it in GitHub Desktop.
c# Properties - Sql Server.sql
SELECT 'public ' +
CASE data_type
WHEN 'bigint' THEN 'int'
-- WHEN 'binary' THEN 'raw'
WHEN 'bit' THEN 'int'
WHEN 'char' THEN 'char'
WHEN 'datetime' THEN 'DateTime'
WHEN 'decimal' THEN 'decimal'
WHEN 'float' THEN 'float'
-- WHEN 'image' THEN 'long raw'
WHEN 'int' THEN 'int'
WHEN 'money' THEN 'double'
WHEN 'nchar' THEN 'string'
WHEN 'ntext' THEN 'string'
WHEN 'nvarchar' THEN 'string'
WHEN 'numeric' THEN 'int'
WHEN 'real' THEN 'decimal'
WHEN 'smalldatetime' THEN 'DateTime'
WHEN 'smallmoney' THEN 'double'
WHEN 'smallint' THEN 'int'
WHEN 'text' THEN 'string'
WHEN 'timestamp' THEN 'Date'
WHEN 'uniqueidentifier' THEN 'string'
--WHEN 'varbinary' THEN 'raw'
WHEN 'varchar' THEN 'string'
ELSE 'CHECK THIS.. ' + data_type + ' DataType'
END + ' ' + COLUMN_NAME + ' { get; set; }'
FROM information_schema.columns
WHERE table_name = 'Products'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment