simple-odata-client / Simple.OData.Client

MIT License
329 stars 192 forks source link

FineEntriesAsync takes so long with Blazor WASM #869

Open AmirImam opened 2 years ago

AmirImam commented 2 years ago

I tried to use Simple.OData.Client with blazor webassembly. It works fine, but FindEntriesAsync takes so long to retrieve data For example, I have a data source that contains about 300 rows, it takes about 1 second to retrieve all data when I call it without Simple.OData.Client, but when I use it, it takes about 10 seconds

.NET 6+ Simple.OData.Client 5.26.0

ysmoradi commented 2 years ago

Could you please provide a simple source code to re-produce the problem?

AmirImam commented 2 years ago

Could you please provide a simple source code to re-produce the problem?

Ok, you can find in this demo the different between FindEntriesAsync and HttpClient.GetFromJsonAsync

AmirImam commented 2 years ago

Another thing, I thought about making a workaround by using GetCommandTextAsync, then sending the command by HttpClient, but GetCommandTextAsync is slow too. I think it is slow because it sends a request for the metadata file in the server, if this request can be canceled, this will be great

ysmoradi commented 2 years ago

I'm gonna put some efforts on this soon

In our applications, we use a technique to generate $metadata at build time and we use that generated string while constructing ODataClient

Could you please run your backend and copy $metadata in directly in your client side code and use that to prevent sending that request?

AmirImam commented 2 years ago

I'm gonna put some efforts on this soon

In our applications, we use a technique to generate $metadata at build time and we use that generated string while constructing ODataClient

Could you please run your backend and copy $metadata in directly in your client side code and use that to prevent sending that request?

Now I tried that by downloading the $metadata.xml file and pass the path to ODataClientSettings like that settings.MetadataDocument = "http://localhost:5078/$metadata.xml"; //localhost just for testing an absolute path but it throws an error Data at the root level is invalid in GetCommandTextAsync()

ysmoradi commented 2 years ago

You've to supply the entire $metadata document! Not the URL! It should be a long text in XML format

AmirImam commented 2 years ago

You've to supply the entire $metadata document! Not the URL! It should be a long text in XML format

Thank you, it works. But of course you know this is just a workaround. If FindEntriesAsync fixed this will be great