Skip to content
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

Allow us call ToSqlQueryText on an IQueryable<T> #578

Closed
mark-manticore opened this issue Jul 19, 2019 · 2 comments · Fixed by #581 or #604
Closed

Allow us call ToSqlQueryText on an IQueryable<T> #578

mark-manticore opened this issue Jul 19, 2019 · 2 comments · Fixed by #581 or #604
Labels
feature-request New feature or request improvement Change to existing functional behavior (perf, logging, etc.)

Comments

@mark-manticore
Copy link

Is your feature request related to a problem? Please describe.
Right now all LINQ queries must go through a unique GetItemLinqQueryable method. This method is different than GetItemQueryIterator and GetItemQueryStreamIterator. The default response factory for LINQ queries is to deserialize into the desired type. If I want to write a LINQ query that returns a stream iterator I cant.

For debugging purposes it's also useful to see the generated SQL statement and log it if it exceeds a certain RU cost. The v2 SDK overwrote the ToString method on the DocumentQuery to facilitate this. A string is loggable, a LINQ query is not.

Describe the solution you'd like
I'd like the SDK to allow me to convert an IQueryable to a SQL string which I can then use to pass to either GetItemQueryIterator or GetItemQueryStreamIterator. From the string I can also log the request if the response exceeds a given amount of RUs (or any other metrics).

Describe alternatives you've considered
Abandoning LINQ and just using strings or forking the repository to make a custom version.

Additional context
A LINQ query is a compile-time type safe way to write queries and IMHO is a far superior approach than writing strings which are harder to refactor and verify are correct. This seems like a local transformation task separate from the query which needs to work with response data.

It also seems like it would simplify the SDK as callers choose to use LINQ or strings and all the query APIs need is to accept a string.

@simplynaveen20 simplynaveen20 added feature-request New feature or request improvement Change to existing functional behavior (perf, logging, etc.) labels Jul 19, 2019
@simplynaveen20
Copy link
Member

Thanks for creating the issue . Will get back to you in this .

@j82w
Copy link
Contributor

j82w commented Jul 22, 2019

I would recommend doing ToQueryDefinition() and adding a ToString to QueryDefinition so it supports parameterized queries.

simplynaveen20 added a commit that referenced this issue Jul 22, 2019
kirankumarkolli pushed a commit that referenced this issue Jul 29, 2019
* closes #578

* adding to sqlquerytext method

* updating changelog

* Making extension public

* Updating contract change UT

* Updating changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request improvement Change to existing functional behavior (perf, logging, etc.)
Projects
None yet
3 participants