Edit Data being sent by OData Service [duplicate]
Im just wondering at the Odata.svc provider end we can change/edit the data being sent over the line to the odata client.
e.g. On retrieve on a customer entity I do not care about all the related entities (which for our scenario there is over 20 which adds up to a lot of extra data going across the line) so the returned entity also includes the related entity add开发者_开发技巧resses:
So in this circumstance I dont want the link refs coming across. Is there a way of doing this other than performing a select? Im hoping we can intercept the data request and chop out these relations and than send the altered atom data.
Thanks
If you can do this on the client, you can use the projections feature: $select. In that way the client can ask only for the properties which it needs and the rest won't be included (this applies to navigation properties as well). On the server, there's currently no simple way of doing this, mainly because it effectively changes the shape of the data, and thus the data returned by the server would not conform to the model described in $metadata endpoint, which might confuse clients. You could intercept the request as it comes to the server (depends on your hosting technology, WCF/ASP.NET or maybe even IDataServiceHost) and add the $select to the URL before it gets processed by the WCF Data Services.
精彩评论