hi guys,
i'm facing an issue with a table which is self-referencing
the server method controller is very simple;
the SQL database includes an optional FK link to self via a parentID
the problem is, when i include data in the DB with a single layer, i.e. no values in parentID, then the API works and returns data....
however when i include links as per the FK then the API fails with a HTTP400
i.e. if the below is NULL, then it all works
how can we further diagnose what's going on. to me this is fairly simple, get everything from that table and order by it's 'Name' field...
this does work okay on the UI
FYI i have tested this with a null clause on the serverMethodController and it's returning as expected
i'm thinking a posisble solution could be to remove the FK at the database level and enforce the relationship via the UI....
i.e. use the UI to allow the user to select and set the Parent ID from a drop down list, however have no underlying FK in the DB, but that would then break the search screen as it needs to pull the parent when required (which is working as per above)
Hi @TMRGlobal,
The exception from the stacktrace in the first screenshot doesn't include any Radzen code. I would start from there.
@korchev
Found it!
it was the JSON serializer, once swapped to newtonsoft, problem solved
// return Ok(System.Text.Json.JsonSerializer.Serialize(result, new JsonSerializerOptions { PropertyNamingPolicy = null }));
//}
return Ok(JsonConvert.SerializeObject(result, new JsonSerializerSettings
{
PreserveReferencesHandling = PreserveReferencesHandling.Objects
}));