2009-09-13 81 views
1

嗨使用亚音速3.0.0.3它似乎有一些问题与亚音速识别存储过程参数作为输出参数。亚音速3无法识别存储过程输出参数

在StoredProcedures.cs类中,我找到了我的存储过程定义,但最后一个参数被错误地定义为“AddParameter”。

sp.Command.AddParameter("HasPermission",HasPermission,DbType.Boolean); 

当我sp.Execute()和试图读取sp.Command.OutputValues [0]的值是空的值。

如果将定义编辑为这样;

sp.Command.AddOutputParameter("HasPermission", DbType.Boolean); 

然后值返回,是正确的值类型

我不知道我怎么“修复”这一点 - 因为每次我回蓝通过“运行自定义工具”参数定义所需的SP类编辑。我应该怎样编辑T4模板?

请指教。

编辑:我忘了提我使用MS SQL 2008(10.0.2531)

+0

我认为这应该处理,也许提交问题跟踪器上的票? http://github.com/subsonic/SubSonic-3.0/issues 这绝对是在T4模板。它可能不正确地检测输出参数以生成正确的代码。 – 2009-09-13 15:46:12

+0

在Github上创建问题; http://github.com/subsonic/SubSonic-3.0/issues#issue/118 – CmdrTallen 2009-09-14 18:40:12

回答

0

与亚音速3.0.0.4这是固定的,但遗憾的是没有希望。修正可以在此博客条目后完成; http://brianmrush.wordpress.com/2010/01/15/subsonic-and-t4-templates/

基本上把这个添加到SQLServer.ttinclude;

p.ParameterDirection = GetParamDirection(row["PARAMETER_MODE"].ToString()); 

并将此方法广告到SQLServer.ttinclude;

string GetParamDirection(string paramMode) 
{ 
    switch (paramMode) 
    { 
    case "IN": 
     return "ParameterDirection.Input"; 
    case "INOUT": 
     return "ParameterDirection.InputOutput"; 
     case "OUT": 
     return "ParameterDirection.Output"; 
    case "RETURN": 
     return "ParameterDirection.ReturnValue"; 
    default: 
     return "ParameterDirection.Input"; 
    } 
} 

然后在StoredProcedure.tt文件中修改第21行看起来像这样;

sp.Command.AddParameter("<#=par.Name#>",<#=par.CleanName#>,DbType.<#=par.DbType#>);