In WCF Data Services, can I enclose a list of references to another entity while creating a new object?
I have a table Article, a table Tag and 开发者_如何学Pythona joint table to associate a tag to an article.
While creating a new Article, by sending a POST request to /Service.svc/Articles, is it possible to enclose in the JSON object a list of Tag ids to be associated?
Something like:
{
title: "My article title",
text: "The content:",
Tags: [ { id: 1 }, { id: 2 }, { id: 3 } ]
}
If not can I send the list of tags in one request? For example:
/Service.svc/Articles(1)/Tags
[ { id: 1 }, { id: 2 }, { id: 3 } ]
Or do I have to make as many requests as they are tags?
Thank you very much in advance.
You can modify just the links by POST/PUT/DELETE to the $links URL as described here: http://www.odata.org/developers/protocols/operations#CreatingLinksbetweenEntries The samples there use ATOM/XML, but the respective JSON format is also possible. To send multiple operations to the server in one request (to save the roundtrips) you can create a batch request as described here: http://www.odata.org/developers/protocols/batch
精彩评论