自动生成Model层中对应表的各个字段

select 
'public '+
case t.name
when 'varchar' then 'string'
when 'smallint' then 'Int16'
when 'int' then 'Int32'
when 'datetime' then 'DateTime'
when 'numeric' then 'double'
else 'string' end +' '
+cl.name+' {get;set;}',
t.name,
cl.max_length,
cl.precision,
cl.scale
from sys.columns cl
left join sys.types t
on cl.user_type_id = t.user_type_id
where object_id=OBJECT_ID('M_user')
order by cl.column_id
原文地址:https://www.cnblogs.com/Sunflower-/p/5545113.html