Skip to content

IAsyncEnumerable on DelayedQuery #364

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

snaumenko-st
Copy link

Introduce IAsyncEnumerable on DelayedQuery to utilize async Session query while asynchronously prefetching data.
We need IAsyncEnumerable implementation here as if it is used inside a Prefetch, which is a fairly common case, it is used as the IEnumerable source and will fall back to a synchronous implementation even in a chain of asynchronous calls. The new unit test shows that behavior.

@alex-kulakov
Copy link
Contributor

alex-kulakov commented Dec 22, 2023

Hello @snaumenko-st,

Oh my gosh, I can feel your frustration when you had an API to change session handler but no way to get current session handler to instantiate yours. Sorry for that. We'll fix it and provide proper way of changing handlers once we have this API.

I also appreciate the test you have created. I have some comments on it.

  1. Managing session services. Don't instantiate session services, don't do it in DataObjects.Net project and in yours as well, use Session.Services.Get<TServiceType>() API, let services be under DataObjects.Net control, it creates them and it should dispose them if needed.
  2. Test. I need you to move your test case to our main test project - Xtensive.Orm.Tests. It has a group of tests connected to Prefetch functionality, they are placed in Xtensive.Orm.Tests/Storage/Prefetch folder, I think you need to put your test cases into PrefetchTest.cs file. The test class populates database with some data so you just need to make some queries.
    Split sync and async cases which are now in one test, let's call tests PrefetchOnDelayedQueryTest and PrefetchOnDelayedQueryAsyncTest. Please, append them to the end of tests region.
    Put your session handler to a separate file in Xtensive.Orm.Tests/Storage/Prefetch folder, it may be useful not only in your case, if so, I will move it later to Tests.Framework project to be available across the test projects.
    BTW, Session.Handler property is available in Xtensive.Orm.Tests project.

@snaumenko-st
Copy link
Author

@alex-kulakov Thanks for your comments. I tried fixing the tests as you suggested and they look a little cleaner now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants