/// <summary> /// Fills the UI field txtSql /// If "original Query" is checked: /// Fill the field txtSql.Text with the appropriate query text and add parameters /// Else: /// Fill the text field txtSql.Text with sql /// </summary> private void FillSqlText() { if (this.chkUseOriginal.Checked) { SqlQueryText qt = this.queryInfos[0]; if (this.radioQuery2.Checked) { qt = this.queryInfos[1]; } String s = qt.Text + "\r\n"; s += "-------------------------------"; for (int i = 0; i < qt.Params.Length; i++) { ParameterText param = qt.Params[i]; if (param.SqlType == "String") { s += "\r\n" + param.Name + " [" + param.SqlType + "]: " + Utils.QuoteString(param.Value); } else { s += "\r\n" + param.Name + " [" + param.SqlType + "]: " + param.Value; } } this.txtSql.Text = s; } else { this.txtSql.Text = this.currentSql; } }
private SqlQueryText[] GetFullQueryInfo(DataContext dataContext, IQueryable query) { System.Data.Common.DbCommand dbCommand = dataContext.GetCommand(query); SqlQueryText[] result = new SqlQueryText[1]; for (int i = 0, n = 1; i < n; i++) { result[i].Text = dbCommand.CommandText; int nParams = dbCommand.Parameters.Count; result[i].Params = new ParameterText[nParams]; for (int j = 0; j < nParams; j++) { ParameterText param = new ParameterText(); System.Data.Common.DbParameter pInfo = dbCommand.Parameters[j]; param.Name = pInfo.ParameterName; param.SqlType = pInfo.DbType.ToString(); Console.WriteLine("Before SqlType= " + param.SqlType); object paramValue = pInfo.Value; if (paramValue == null) { param.Value = null; } else { param.Value = pInfo.Value.ToString(); } result[i].Params[j] = param; } } return(result); }
private SqlQueryText[] GetFullQueryInfo(DataContext dataContext, IQueryable query) { System.Data.Common.DbCommand dbCommand = dataContext.GetCommand(query); SqlQueryText[] result = new SqlQueryText[1]; for (int i = 0, n = 1; i < n; i++) { result[i].Text = dbCommand.CommandText; int nParams = dbCommand.Parameters.Count ; result[i].Params = new ParameterText[nParams]; for (int j = 0; j < nParams; j++) { ParameterText param = new ParameterText(); System.Data.Common.DbParameter pInfo = dbCommand.Parameters[j]; param.Name = pInfo.ParameterName; param.SqlType = pInfo.DbType.ToString(); Console.WriteLine("Before SqlType= " + param.SqlType); object paramValue = pInfo.Value; if (paramValue == null) { param.Value = null; } else { param.Value = pInfo.Value.ToString(); } result[i].Params[j] = param; } } return result; }