Description
My use case: I have a facility that retrieves data from many entities, and allows for several usage patterns, such as: 1) retrieve page-by-page, 2) retrieve all, 3) retrieve range (skip+take), or 4) retrieve one item. In the beginning, I don't know which usage pattern it is going to be — this is up to a remote client calling my service. The client does specify retrieval conditions, such as filters and sort order. Hence, I need to construct the query dynamically.
Hence, the call sequence of my facility is, for example, as follows:
Initialize(setup)
— setting up the queryGetCount()
— retrieve total amount of itemsGetPage(index)
— retrieve a page of dataGetPage(index)
— retrieve another page of dataGetDetail(id)
—retrieve some more details for a particular item
Now in the Initialize()
method I want to prebuild queries which I will need later. I do not want to execute them, just prepare and compile the query. Later, when (if) the client calls the GetPage()
method, I execute the relevant query, submitting the page index.
Currently, I have to delay query construction until the first invocation of the method which uses it, e.g. GetPage()
. For my case, this is suboptimal, because the client can freely mix different usage patterns, and because my Initialize()
method can run in parallel, I would like to prepare all needed queries at once. Another important aspect is that building the query is a fairly complex task, due to the user-submitted filter, and I want to compute this just once as a base, and reuse for all three queries.
I believe that either making CompiledQueryRunner
, or adding a CreateCompiledQuery()
method on QueryEndpoint
could solve this case.