tags:

views:

10

answers:

1

I have a large database with 1000s of stored procedures.. But I need to use only some of 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.

A: 

Here's What I did:

  1. 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' ";

  2. 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;

    }

Zorg