【问题标题】:WCF Service - return the output parameter from a stored procedure in Entity ModelWCF 服务 - 从实体模型中的存储过程返回输出参数
【发布时间】:2013-07-11 08:10:04
【问题描述】:

我有一个用于身份验证的存储过程,获取登录名和密码并返回一个字符串。我想从我的 WCF 数据服务(使用实体模型和函数导入)调用存储过程(sql server 2005)并返回输出参数(字符串)作为结果。

我正在使用函数导入来映射存储过程。我应该如何进行?

【问题讨论】:

    标签: sql-server wcf stored-procedures output-parameter


    【解决方案1】:

    终于有答案了!!我们必须使用输出参数,将其作为参数提供给被调用的存储过程,最后只需通过类型转换,我们就可以使用该值。 (我的返回格式是 JSON,但它同样适用于 XML 格式) 界面 : [运营合同] [WebInvoke(方法=“GET”, BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, UriTemplate = "认证/{login}/{pwd}")]

    Implementation: 
    public string authenticate(string login, string pwd)
    {
    SteelcaseMigrationEntities entities = new SteelcaseMigrationEntities();
    
    System.Data.Objects.ObjectParameter output =  
    new     System.Data.Objects.ObjectParameter("out", typeof(string));
    entities.authenticate_android(login, pwd, output);
    //Console.Write(output.Value)
    string result = (string)output.Value;
    return result;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-17
      • 1970-01-01
      • 2012-12-24
      相关资源
      最近更新 更多