存储过程中的参数自动生成函数参数,表中的列自动生成函数参数 CodeSmith模板
大家在项目中我想都有这样的体会,一个存储过程有大量的参数,在写函数的时候就要写大量重复的代码,还要在在SQL 和VS 之间来回的切换查看参数,数据表同样也是,所以写了两个模板来加快开发效率希望大家喜欢,模板可以根据自已的习惯稍做修改就可以使用。
存储过程示例如下:
Create PROCEDURE [dbo].[CreateUpdateDelete_NewsArticleEntity]
@DataAction int,
@articleid int = 0,
@sortid int,
@title varchar(100),
@source varchar(50),
@author varchar(50),
@topnews bit,
@description text,
@hitrate int,
@adddate datetime,
@lastupdate datetime,
@editor varchar(50),
@userid int,
@visible bit,
@openread bit,
@keyword varchar(100),
@img varchar(50)
生成代码如下:
SqlParameter[] _param={
SqlHelper.MakeInParam("@DataAction",""),
SqlHelper.MakeInParam("@articleid",""),
SqlHelper.MakeInParam("@sortid",""),
SqlHelper.MakeInParam("@title",""),
SqlHelper.MakeInParam("@source",""),
SqlHelper.MakeInParam("@author",""),
SqlHelper.MakeInParam("@topnews",""),
SqlHelper.MakeInParam("@description",""),
SqlHelper.MakeInParam("@hitrate",""),
SqlHelper.MakeInParam("@adddate",""),
SqlHelper.MakeInParam("@lastupdate",""),
SqlHelper.MakeInParam("@editor",""),
SqlHelper.MakeInParam("@userid",""),
SqlHelper.MakeInParam("@visible",""),
SqlHelper.MakeInParam("@openread",""),
SqlHelper.MakeInParam("@keyword",""),
SqlHelper.MakeInParam("@img",""),
};
模板下载/Files/shoucao/shoucao.rar
存储过程示例如下:
Create PROCEDURE [dbo].[CreateUpdateDelete_NewsArticleEntity]
@DataAction int,
@articleid int = 0,
@sortid int,
@title varchar(100),
@source varchar(50),
@author varchar(50),
@topnews bit,
@description text,
@hitrate int,
@adddate datetime,
@lastupdate datetime,
@editor varchar(50),
@userid int,
@visible bit,
@openread bit,
@keyword varchar(100),
@img varchar(50)
生成代码如下:
SqlParameter[] _param={
SqlHelper.MakeInParam("@DataAction",""),
SqlHelper.MakeInParam("@articleid",""),
SqlHelper.MakeInParam("@sortid",""),
SqlHelper.MakeInParam("@title",""),
SqlHelper.MakeInParam("@source",""),
SqlHelper.MakeInParam("@author",""),
SqlHelper.MakeInParam("@topnews",""),
SqlHelper.MakeInParam("@description",""),
SqlHelper.MakeInParam("@hitrate",""),
SqlHelper.MakeInParam("@adddate",""),
SqlHelper.MakeInParam("@lastupdate",""),
SqlHelper.MakeInParam("@editor",""),
SqlHelper.MakeInParam("@userid",""),
SqlHelper.MakeInParam("@visible",""),
SqlHelper.MakeInParam("@openread",""),
SqlHelper.MakeInParam("@keyword",""),
SqlHelper.MakeInParam("@img",""),
};
模板下载/Files/shoucao/shoucao.rar