views:

106

answers:

1

I am trying to use asp.net MVC controllers JsonResult to CRUD db records.

e.g.

GET /Config/Folder/1 - will return a json serialized LinqToSql entity
POST /Config/Folder - will send form data back to the server to be deserialized and persisted back to the database.

I am using james newton-kings JSON.net to serialize the entity, although I get a 'specified cast is invalid' at the moment, if it does work I will still end up with a large JSON object which would probably contain more information than necessary (and more than I really want to send to the client).

Is there a neat solution for returning a 'simplified' JSON version of my entity to the client and then also, on POST, updating the entity.

I was thinking using partial classes to mark the properties with the [JsonIgnore]... but it just doesnt feel very tidy.

Any suggestions?

A: 

Any internal properties are not serialize by the Json( object ) method. Maybe it could help you.

Hapkido