Subsonic 3: How do I generate predefined set of stored procedures?
I have a large database with 1000s of stored procedures.. But I need to use only some o开发者_开发问答f them (say about 25 stored procs out of 1000). What should I change in T4 templates to limit the code generation to only those stored procedures that I need? Otherwise Subsonic 3 will generate all of them...
Thanks, Zohrab.
Here's What I did:
Added following into SQLServer.ttinclude
// Customize the SP list here
const string SP_SQL=@"SELECT* FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' AND ROUTINE_NAME = 'My Stored Procedure Name' OR ROUTINE_NAME = 'My other Stored Procedure Name' ";
Replaced List GetSPs method in SQLServer.ttinclude with following:
List<SP> GetSPs(){ var result=new List<SP>(); //[Z.B.]pull the stored procedures in a reader using(IDataReader rdr=GetReader(SP_SQL)){ while(rdr.Read()){ var sp=new SP(); sp.Name = rdr["ROUTINE_NAME"].ToString(); sp.CleanName=CleanUp(sp.Name); sp.Parameters=GetSPParams(sp.Name); result.Add(sp); } } return result;
}
精彩评论