Stored procedures 亚音速3.0存储过程生成

Stored procedures 亚音速3.0存储过程生成,stored-procedures,subsonic3,Stored Procedures,Subsonic3,使用亚音速3.0.0.3和StoredProcedures.tt模板时,生成的代码不会编译并抛出错误: …'DB'不包含“提供程序”的定义 这在存储过程的调用方法中 StoredProcedure sp = new StoredProcedure("Company_Get", this.Provider); 我是否遗漏了一些东西,或者在3.0模板中是否有一个bug,用于生成存储过程的包装器?我想我们中那些想要使用亚音速v3的人处于领先地位。我还需要使用context.tt生成代码。这纠正了我的

使用亚音速3.0.0.3和
StoredProcedures.tt
模板时,生成的代码不会编译并抛出错误:

…'DB'不包含“提供程序”的定义

这在存储过程的调用方法中

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

我是否遗漏了一些东西,或者在3.0模板中是否有一个bug,用于生成存储过程的包装器?

我想我们中那些想要使用亚音速v3的人处于领先地位。我还需要使用context.tt生成代码。这纠正了我的问题。这确实是很酷的东西,但是屏幕显示和文档都跟不上产品发展的速度

我相信您几年前就知道了答案,但您需要运行所有ActiveRecord模板,包括Struct和Context

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();
    }
}