2009-08-04 13 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

これまでの答えは分かりましたが、構造とコンテキストを含むすべての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(); 
    } 
}