Now we will establish a breakpoint in one of the methods that builds a LINQ query against the Cosmos DB database to inspect the SQL API query that LINQ generates. This way, we will be able to grab the SQL queries and run them in our favorite tool to query the document collection. In addition, we will learn how to add the necessary code to print the generated SQL query in the debug output whenever necessary.
Go to the following line within the GetCompetitionByTitleWithLinq
static method:
while (documentQuery.HasMoreResults)
Right-click on the line and select Breakpoint | Insert breakpoint
in the context menu.
Start debugging the application.
Inspect the value for documentQuery
and Visual Studio will display a JSON key-value pair with the generated SQL API query string in the value for the "query"
key, as shown in the following screenshot:
We can add the following line to display the query key and its value to the debug output:
System.Diagnostics...