Reputation: 101
I am trying to run an example in the MCTS 70-516 book, more specifically the example on page 470.
Requirements / what to create:
Northwind
databaseCustOrderHist
stored procedureThe following .svc
file is then created:
using System.Data.Services;
using System.Linq;
using System.ServiceModel.Web;
namespace WcfDataServicesLibrary
{
public class NorthwindService : DataService<NorthWindEntities>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*",EntitySetRights.All);
config.SetServiceOperationAccessRule("*",ServiceOperationRights.All);
config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
}
[WebGet]
public IQueryable<CustOrderHist_Result> CustOrderHist(string customerID)
{
using(NorthWindEntities db = new NorthWindEntities())
{
return CustOrderHist(customerID).ToList().AsQueryable();
}
}
}
}
I then try to run it as indicated in the text:
"http://localhost:65363/NorthwindService.svc/CustOrderHist?customerID='ALFKI'"
I then get the error message StackOwerFlowException.
Why ?
I have tried the following:
No change. The same result.
I have a 32 bit machine (Windows Vista). So 64 bit is not an issue.
Any clues would be greatly appreciated.
Upvotes: 0
Views: 411
Reputation: 286
There is recursion in the CustOrderHist method
Try the following:
[WebGet]
public IQueryable<CustOrderHist_Result> CustOrderHist(string customerID)
{
using(NorthWindEntities db = new NorthWindEntities())
{
return db.CustOrderHist(customerID).ToList().AsQueryable();
}
}
Upvotes: 1