public void FormatSql() { var tokenized = _tokenizer.TokenizeSQL(DisplayedSql); var parsed = _parser.ParseSQL(tokenized); DisplayedSql = _formatter.FormatSQLTree(parsed); }
public async Task <DocumentListModel> GetDocuments(string sql, Dictionary <string, object> parameters, int maxItems) { if (parameters == null) { parameters = new Dictionary <string, object>(); } var sqlParams = new SqlParameterCollection(); foreach (var kv in parameters) { sqlParams.Add(new SqlParameter($"@{kv.Key}", kv.Value)); } //sql = NSQLFormatter.Formatter.Format(sql); var tokenized = _tokenizer.TokenizeSQL(sql); var parsed = _parser.ParseSQL(tokenized); sql = _formatter.FormatSQLTree(parsed); var sqlQuery = new SqlQuerySpec(sql, sqlParams); var docs = await this._client.CreateDocumentQuery <Document>(_collection.SelfLink, sqlQuery, new FeedOptions() { MaxItemCount = maxItems, EnableScanInQuery = true }).QueryAsync(1); return(new DocumentListModel( docs.Select(d => new DocumentModel(this._client, this, d)).ToList(), sql, parameters)); }
private void DoFormatting() { var tokenizedSql = _tokenizer.TokenizeSQL(txt_Input.Text); if (!splitContainer4.Panel2Collapsed && !splitContainer5.Panel1Collapsed) { txt_TokenizedSql.Text = tokenizedSql.PrettyPrint(); } var parsedSql = _parser.ParseSQL(tokenizedSql); if (!splitContainer4.Panel2Collapsed && !splitContainer5.Panel2Collapsed) { txt_ParsedXml.Text = parsedSql.OuterXml; } webBrowser_OutputSql.SetHTML(_formatter.FormatSQLTree(parsedSql)); }