I am creating a ASP.Net Web API to expose an existing database for use with handheld devices. I am also relatively new at Web API, EF, and everything else I’m trying to use on this project 🙂
I want the resulting data transfer to be as lightweight as possible but when the api returns an object, the serialized JSON has ‘EntityKey’ fields for itself and the rows from other tables that the object has a relationship with.
I’m now trying to use the ADO.NET DbContext Template Generator for the model code generation. This gets rid of the EntityKey fields but I still have the relationships showing up in the JSON.
All I want are the fields from the object to be serialized and to be able to deserialize JSON into these objects for inserts and updates. Is there a built-in way to do this?
What’s my best bet?
in your return value “select” a new type
where these are the values that you want to return
if you post some example code it might be easier to give you a more relevant code example
using your book
change to
OR
OR (for reference sake – I’d use dynamic or object for the api rather than a JsonResult)
note if you’re using
and if you’re using httpget as opposed to post, then you’d need to use