ODataLib does not know (and should not know) that it is reading the response of a service operation. The only thing that matters is what kind of payload you want to read.
It depends on what the service operation returns. If it returns a single record, use ODataLib in the same way as reading unidirectional payloads (e.g. ~ / Products (0)), since the wire format will be the same. If the service operation returns a collection of objects, read it as a feed.
If the service operation returns a single primitive or complex value, you can use ODataMessageReader.ReadProperty. I know that the method name is a little misleading, but again because the property payload (e.g. ~ / Products (0) / Name) and the maintenance operation returning a primitive or complex type use the same payload format . In this case, you should ignore the name of the returned property (this is probably the name of the service operation).
If the service operation returns a collection of primitive or complex values, you can use ODataMessageReader.CreateODataCollectionReader. This will return the ODataCollectionReader reader, which you use in a very similar way to the ODataReader. The interesting things that he presents are the elements of the collection in question (the API in this case is pretty easy to understand).
It doesn’t matter if you need to read ATOM or JSON, what is up to you, the API is the same.
source share