I have a webpage that should show a datatable on a getrequest. It works fine on a single table, but if the table has a one to many relationship - it gives error.
public IEnumerable<Måledata> Get()
{
using (SCTHDBEntitiesNew e = new SCTHDBEntitiesNew())
{
return e.Måledata.ToList();
}
}
The error it gives:
{"Message":"An error has occurred.","ExceptionMessage":"The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.","ExceptionType":"System.InvalidOperationException","StackTrace":null,"InnerException":{"Message":"An error has occurred.","ExceptionMessage":"Error getting value from 'BuildBoard' on 'System.Data.Entity.DynamicProxies.Måledata_1EDB55943DE25861C91C9B0997AA34B305E0BBE0570E46E0B9205C41772E4B1A'.","ExceptionType":"Newtonsoft.Json.JsonSerializationException","StackTrace":" ved Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)\r\n ved Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)\r\n ved Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n ved.........
Hoping someone can help - longterm ongoing annoying problem