Skip to content

Instantly share code, notes, and snippets.

@jsm85
Last active August 29, 2015 14:06
Show Gist options
  • Save jsm85/409c7f33274d092205f1 to your computer and use it in GitHub Desktop.
Save jsm85/409c7f33274d092205f1 to your computer and use it in GitHub Desktop.
Database Table to Poco
declare @tableName nvarchar(75)
Select @tableName = ''
select
'public ' +
case c.system_type_id
when 127 then 'Int64'
when 108 then 'decimal'
when 56 then 'int'
when 52 then 'int'
when 175 then 'string'
when 231 then 'string'
when 167 then 'string'
when 231 then 'string'
when 61 then 'DateTime'
when 104 then 'bool'
else 'string'
end + ' ' +
c.[name] + ' ' +
'{ get; set; }'
from
sys.columns c
inner join
sys.tables t on t.object_id = c.object_id
where
t.name = @tableName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment