2009-08-04 3 views
0

음속 3.0.0.3 및 StoredProcedures.tt 템플릿을 사용하여 생성 된 코드를 컴파일하고, 오류가 발생하지 않을 것이다 :음속 3.0 프로 시저 발생

... 'DB' does not contain a definition for 'Provider' ...

을 이것은 SPROC위한 호출 방법이다.

StoredProcedure sp = new StoredProcedure("Company_Get", this.Provider); 

뭔가가 누락되었거나 저장 프로 시저 주위에 래퍼 생성을위한 템플릿에 버그가 있습니까?

답변

1

나는 SubSonic의 v3를 사용하고자하는 사람들이 최첨단에 있다고 생각합니다. context.tt로 코드를 생성해야했습니다. 이 문제가 해결되었습니다. 이것은 정말 멋지지만 화면 캐스트와 문서는 제품이 얼마나 빨리 진화하고 있는지를 파악하지 못합니다.

0

저는 몇 년 전에 해답을 얻었지만 Struct와 Context를 포함한 모든 ActiveRecord 템플릿을 실행해야합니다.

1
public ProcedureParameters Parameters 
{ 
    get 
    { 
     return sp; 
    } 
    set 
    { 
     sp = value; 
    } 
} 

# region "Constructors" 

public ExecuteProcedures(int ParameterLength, string ConnectionString):base(true,ConnectionString) 
{ 
    sp = new ProcedureParameters(ParameterLength); 
    strConnection = ConnectionString; 
} 

#endregion 

# region "Execute Procedures" 

public bool InvokeProcedure(string ProcedureName, SqlTransaction SqlTrn, SqlConnection con) 
{ 
    SqlCommand Sqlcmd = new SqlCommand(); 

    try 
    { 
     Sqlcmd.CommandType = CommandType.StoredProcedure; 
     Sqlcmd.Connection = con; 
     Sqlcmd.Transaction = SqlTrn; 

     Sqlcmd.CommandText = ProcedureName; 
     Sqlcmd.Parameters.AddRange(sp.ParameterCollection); 
     Sqlcmd.ExecuteNonQuery();     
     return true; 
    } 
    catch (Exception e) 
    { 
     con.Close(); 
     SqlTrn.Rollback(); 
     throw new Exception("Error Occured :-" + e.Message, e); 
    } 
    finally 
    {    
     Sqlcmd.Dispose(); 
    } 
} 

public bool InvokeProcedure(string ProcedureName) 
{ 
    SqlCommand Sqlcmd = new SqlCommand(); 
    SqlConnection con = new SqlConnection(strConnection); 

    try 
    { 
     Sqlcmd.CommandType = CommandType.StoredProcedure; 
     Sqlcmd.Connection = con; 

     Sqlcmd.CommandText = ProcedureName; 
     Sqlcmd.Parameters.AddRange(sp.ParameterCollection); 

     con.Open(); 
     Sqlcmd.ExecuteNonQuery(); 
     return true; 
    } 
    catch (Exception e) 
    { 
     throw new Exception("Error Occured :-" + e.Message, e); 
    } 
    finally 
    { 
     con.Close(); 
     Sqlcmd.Dispose(); 
     con.Dispose(); 
    } 
}