-- =============================================
-- Author: <shipeng.wang>
-- Create date: <2010-11-15>
-- Description: <根据表名创建实体类的字段和属性>生成c#3.0语法
-- =============================================
create proc [dbo].[sp_wsp_3]
@tbname varchar(20)
as
declare @sql varchar(1000)
set @sql='public class '+@tbname+char(13)+'{'
select @sql=@sql+CHAR(13)+CHAR(9)+'public '+
case when b.name in('image','uniqueidentifier','ntext','varchar','ntext','nchar','nvarchar','text','char') then 'string'
when b.name in('tinyint','smallint','int','bigint') then 'int'
when b.name in('datetime','smalldatetime') then 'DateTime'
when b.name in('float','decimal','numeric','money','real','smallmoney') then 'decimal'
when b.name ='bit' then 'bool'
else b.name end
+' '+a.name+' {get; set;} '
from syscolumns a,systypes b
where a.id=OBJECT_ID(@tbname) and b.status=0
and a.xtype=b.xtype
set @sql=@sql+char(13)+'}'
print @sql