Open GLuca74 opened 1 month ago
Is there a particular reason why you are not using the native OData client to read the OData payloads? I'd recommend using that if you can, otherwise you are going to be reinventing the wheel a lot.
Hello @julealgon , in the last years i wrote a no relational provider for entityframework core for a custom protocol. In the last months i rewrote the provider separating the part that comunicate with efcore structure and the part that implements my protocol. As result I have an assembly that is equivalent to Microsoft.EntityFrameworkCore.Relational(but for no relational) and an assembly that just implements my protocol. Now, using my no relational assembly I am writing an OData provider for entity framework core, so my code is running inside the SaveChange implementation of Entity framework. As general rule, I not like add reference to other assembly, for many reasons, if I fond a bug I have no control on the time to fix it, the support can ends etc. But in this specific case, OData client need its generated models to work while I have not a fixed model to work with because it depend on the model of the developer that uses my provider and honestly I can not image (and I not want to face) wath may means make ODataClient work with a "Dynamic" model.
Another reason is that OData Client returns already instanciated objects, I not need this, it is redundant because the object creation and properties assignments are made in the efcore shaper, I will be forced to generate all objects twice.
Thanks for clarifying @GLuca74 , sounds like you have a fairly low-level, advanced case.
I know this doesn't necessarily answer your specific question, but have you tried using JSON OData batch request/responses instead of the raw multipart request approach? That format should be substantially simpler to parse as it returns a single JSON object like a normal API would.
good morning @julealgon, yes, I saw that option and it is very confortable, but it was introduced in OData 4.01. This means that if i choice that way, I will be not able to use my provider with older version. Other OData servers may not implement this feature. I prefer try to implement the multipart rappresentation first, this gives me a wider range of use of my provider.
Hi @GLuca74. it was introduced in OData 4.01 - I don't believe this statement statement is valid. Json batch requests and responses are supported in OData V4
Hi @gathogojr , I read this : https://docs.oasis-open.org/odata/new-in-odata/v4.01/cn04/new-in-odata-v4.01-cn04.html#_Toc21700090
"8.11 New: JSON Batch Requests and Responses Version 4.0 only defined a multipart format for describing batch requests and responses, which was somewhat hard to implement.
Version 4.01 introduces an alternative JSON format for batch requests and responses, so clients can now use off-the-shelf JSON libraries to compose batch requests and consume batch responses. Combined with the CSDL JSON representation [OData-CSDLJSON] this allows pure JSON communication with OData 4.01 services."
Hello, I am trying to build an OData server using Microsoft.AspnetCore.OData. I have a problem when I try to send a Batch request with a multipart request. The problem seems happend in the response. In this repository,
https://github.com/GLuca74/TestOData
, there is a solution with 3 projects :TestODataServer - The server TestODataClient - The client TestODataModels - A shared Entity
the client request is processed by the server and it is able to receive the response, but when I try to read the actual response I get an error. To read the response I use Microsoft.AspNet.WebApi.Client. This is the code :
The exception is :
sniffing request and response with Fiddler, i have this :
It seems that ReadAsHttpResponseMessageAsync not like this
I tryed in a custom
ODataBatchHandler
to found a way to addmsgtype=response
to the response but i wanst able to found if is possible and whereI also tryed to use
Microsoft.OData.Client
and it works without problems, but I can not use this library.Can you help me found a solution?