WCF数据服务存储过程返回奇怪的字符串值
存储过程:WCF数据服务存储过程返回奇怪的字符串值,wcf,dataservice,Wcf,Dataservice,存储过程: ALTER PROCEDURE [dbo].[TestDataSP] AS BEGIN SELECT FirstName FROM Employees WHERE EmployeeID = 7 END TaskTrackerDataService.cs [WebGet] public String GetEmployeeName() { TaskTracker_EDM.TaskTrackerEntities ctx = new TaskTrac
ALTER PROCEDURE [dbo].[TestDataSP]
AS
BEGIN
SELECT FirstName
FROM Employees
WHERE EmployeeID = 7
END
TaskTrackerDataService.cs
[WebGet]
public String GetEmployeeName()
{
TaskTracker_EDM.TaskTrackerEntities ctx = new TaskTracker_EDM.TaskTrackerEntities();
return ctx.TestDataSP().FirstOrDefault();
}
我有一个存储过程,我可以从Web调用它
http:localhost:2402/TaskTrackerDataService.svc/GetEmployeeName
它将返回员工姓名
<GetEmployeeName xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">Keko88</GetEmployeeName>
任何帮助,请错误是
始终返回“System.Data.Services.Client.QueryOperationResponse`1[System.String]”
因此,添加single,它将正确返回字符串结果
字符串emps1=ctxDSvc.Execute(新Uri(“http:localhost:2402/TaskTrackerDataService.svc/GetEmployeeName”)).Single()
错的是
字符串emps1=ctxDSvc.Execute(新Uri(“http:localhost:2402/TaskTrackerDataService.svc/GetEmployeeName”)).ToString()
TaskTrackerDataService.TaskTrackerEntities ctxDSvc = new TaskTrackerDataService.TaskTrackerEntities(new Uri("http:localhost:2402/TaskTrackerDataService.svc"));
String emps1 = ctxDSvc.Execute<String>(new Uri("http:localhost:2402/TaskTrackerDataService.svc/GetEmployeeName")).ToString();
Console.WriteLine(string.Format("ID: {0} ==== ==== ==== ", emps1));
"System.Data.Services.Client.QueryOperationResponse`1[System.String]"