I created a very simple MVC 4 with Web API project in visual studio Web Developer 2010.
It tries to connect a SQL Server database and pull out the data from a table.
In the api controller, I wrote:
// GET api/gcurobservation/5
public IQueryable<GCUR_OBSERVATION> Get(int id)
{
return gcurObsRepo.FindGCURObservationByLocId(id);
}
The repository class, method "FindGCURObservationByLocId" is defined:
// Query Methods
public IQueryable<GCUR_OBSERVATION> FindGCURObservationByLocId(int locId)
{
var records = from l in db.GCUR_OBSERVATIONs
where l.LocationId == locId
orderby l.ObservationId
select l;
return records;
}
In the debug mode, I could see each GCUR_OBSERVATION object returned from the query. So I am pretty sure the repository works OK but the controller code threw the following error:
An unhandled exception of type 'System.StackOverflowException' occurred in System.Runtime.Serialization.dll
Any tips? Thanks!
Cheers, Alex