Stored procedure:
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();
}
I have a stored procedure, I can call it from Web
http:localhost:2402/TaskTrackerDataService.svc/GetEmployeeName
it will return the Employee name
<GetEmployeeName xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">Keko88</GetEmployeeName>
When I try to call the stored procedure from the my WPF project
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));
it always returns
"System.Data.Services.Client.QueryOperationResponse`1[System.String]"
Any help, please
The error was always return "System.Data.Services.Client.QueryOperationResponse`1[System.String]"
so add single and it will return the string result right
String emps1 = ctxDSvc.Execute(new Uri("http:localhost:2402/TaskTrackerDataService.svc/GetEmployeeName")).Single();
the wrong one was String emps1 = ctxDSvc.Execute(new Uri("http:localhost:2402/TaskTrackerDataService.svc/GetEmployeeName")).ToString();