-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using typed queries becomes extremely slow on conversion #240
Comments
Hi, |
I think ToList just materializes every element (due to lazy loading). You can add a ToList() to the second piece of code and still works very quickly in comparison. After checking the source code on how Simple Odata Client converts from a Dictionary<string, object> to a concrete instance, it seems it relies a lot of reflection and other stuff for datatype conversions, which may make it so slow (just guessing). My other guess is that serializing and deserializing from JSON is a blazing fast operation. I should profile it further to ensure my statements, but those are my two cents. |
Thanks for the observation. Yes it must be it. But why ToDictionary isn't called in the second scenario? I am bit puzzled how JSON serialization may change it. Will appreciate more information. |
The return type of the second FindEntriesAsync is When I call the Json serialize function over that list of dictionaries, internally iterates over the enumerable (therefore no need to call toList to materialize the results) , it turns the result into a series of key/pair values like "member": "value" (as it should be, given that it is a Dictionary). With that format, Json.Net is very efficient on deserializing it on every other type (like the Transaction class in my case). |
Thank you, I will investigate it further. |
Any news on this? The "slow" callstack ist often something like:
|
@Amberg What version are you using, the reflection performance issues were addressed by 5.6+ |
I ran into this problem today. The initial behavior that @Rydra described is still present in version 6.0.1. His fix with JsonConvert works too. If anybody runs into problems with nullvalues. You can fix this by using |
I have the following query:
while this works and maps the properties every retrieved Transaction entry properly (I'm using JsonProperty attributes on every member of the Transaction class), when the number of entries scales up to the thousands, it is extremely slow (for example, for 5000 records it's taking minutes).
Doing a small JSON.Net trick for conversion has lead me to the same result in just a matter of seconds, like this:
What's the problem down there? Why is the regular conversion of entities so slow?
Thank you.
The text was updated successfully, but these errors were encountered: