Last active
August 29, 2015 14:06
-
-
Save jsm85/409c7f33274d092205f1 to your computer and use it in GitHub Desktop.
Database Table to Poco
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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