Skip to content

Instantly share code, notes, and snippets.

@xwiz
Forked from pdwetz/gist:5368441
Created June 17, 2013 22:03
Show Gist options
  • Save xwiz/5800904 to your computer and use it in GitHub Desktop.
Save xwiz/5800904 to your computer and use it in GitHub Desktop.

Revisions

  1. @pdwetz pdwetz created this gist Apr 12, 2013.
    21 changes: 21 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    select 'replacewithtablename' into @table;
    select 'replacewithdatabasename' into @schema;

    select concat('public class ',@table,'{')
    union

    select concat('public ',tps.dest,' ',column_name,'{get;set;}')
    from information_schema.columns c
    join (
    select 'char' as orign ,'string' as dest union all
    select 'varchar' ,'string' union all
    select 'datetime' ,'DateTime' union all
    select 'date' ,'DateTime' union all
    select 'text' ,'string' union all
    select 'int' ,'int' union all
    select 'decimal' ,'decimal' union all
    select 'tinyint' ,'bool'
    ) tps on c.data_type like tps.orign
    where table_schema=@schema and table_name=@table union

    select '}';