dataobjects-net icon indicating copy to clipboard operation
dataobjects-net copied to clipboard

Make CompiledQueryRunner public: allow compiling queries without executing them

Open ondrejtucny opened this issue 2 years ago • 6 comments

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:

  1. Initialize(setup) — setting up the query
  2. GetCount() — retrieve total amount of items
  3. GetPage(index) — retrieve a page of data
  4. GetPage(index) — retrieve another page of data
  5. GetDetail(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.

ondrejtucny avatar Dec 18 '22 20:12 ondrejtucny