Sql server WCF服务-从实体模型中的存储过程返回输出参数
我有一个用于身份验证、获取登录名和密码并返回字符串的存储过程。我想从我的WCF数据服务(使用实体模型和函数导入)调用存储过程(sql server 2005),并返回输出参数(字符串)作为结果Sql server WCF服务-从实体模型中的存储过程返回输出参数,sql-server,wcf,stored-procedures,output-parameter,Sql Server,Wcf,Stored Procedures,Output Parameter,我有一个用于身份验证、获取登录名和密码并返回字符串的存储过程。我想从我的WCF数据服务(使用实体模型和函数导入)调用存储过程(sql server 2005),并返回输出参数(字符串)作为结果 我正在使用函数导入映射存储过程。我应该如何进行 终于找到答案了!!我们必须使用输出参数,将其作为被调用存储过程的参数,最后通过类型转换,我们可以使用该值。(我的返回格式是JSON,但对XML格式同样有效) 接口: [经营合同] [WebInvoke(Method=“GET”, BodyStyle=WebM
我正在使用函数导入映射存储过程。我应该如何进行 终于找到答案了!!我们必须使用输出参数,将其作为被调用存储过程的参数,最后通过类型转换,我们可以使用该值。(我的返回格式是JSON,但对XML格式同样有效) 接口: [经营合同] [WebInvoke(Method=“GET”, BodyStyle=WebMessageBodyStyle.Wrapped, ResponseFormat=WebMessageFormat.Json, RequestFormat=WebMessageFormat.Json, UriTemplate=“authenticate/{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;
}