public override string ToString()
 {
     SqlDataSourceColumnData data = new SqlDataSourceColumnData(this._designerDataConnection, this._designerDataColumn);
     if (this._isDescending)
     {
         return (data.EscapedName + " DESC");
     }
     return data.EscapedName;
 }
 public override string ToString()
 {
     SqlDataSourceColumnData data = new SqlDataSourceColumnData(this._designerDataConnection, this._designerDataColumn);
     if (this._isBinary)
     {
         return string.Format(CultureInfo.InvariantCulture, this._operatorFormat, new object[] { data.EscapedName, this._value });
     }
     return string.Format(CultureInfo.InvariantCulture, this._operatorFormat, new object[] { data.EscapedName });
 }
        public override string ToString()
        {
            SqlDataSourceColumnData data = new SqlDataSourceColumnData(this._designerDataConnection, this._designerDataColumn);

            if (this._isDescending)
            {
                return(data.EscapedName + " DESC");
            }
            return(data.EscapedName);
        }
        public override string ToString()
        {
            SqlDataSourceColumnData data = new SqlDataSourceColumnData(this._designerDataConnection, this._designerDataColumn);

            if (this._isBinary)
            {
                return(string.Format(CultureInfo.InvariantCulture, this._operatorFormat, new object[] { data.EscapedName, this._value }));
            }
            return(string.Format(CultureInfo.InvariantCulture, this._operatorFormat, new object[] { data.EscapedName }));
        }
 private void AppendWhereClauseParameter(StringBuilder commandText, SqlDataSourceColumnData columnData, string oldValuesFormatString)
 {
     string escapedName = columnData.EscapedName;
     string oldValueParameterPlaceHolder = columnData.GetOldValueParameterPlaceHolder(oldValuesFormatString);
     if (columnData.Column.Nullable)
     {
         commandText.Append("((");
         commandText.Append(escapedName);
         commandText.Append(" = ");
         commandText.Append(oldValueParameterPlaceHolder);
         commandText.Append(") OR (");
         commandText.Append(escapedName);
         commandText.Append(" IS NULL AND ");
         commandText.Append(oldValueParameterPlaceHolder);
         commandText.Append(" IS NULL))");
     }
     else
     {
         commandText.Append(escapedName);
         commandText.Append(" = ");
         commandText.Append(oldValueParameterPlaceHolder);
     }
 }
        private void AppendWhereClauseParameter(StringBuilder commandText, SqlDataSourceColumnData columnData, string oldValuesFormatString)
        {
            string escapedName = columnData.EscapedName;
            string oldValueParameterPlaceHolder = columnData.GetOldValueParameterPlaceHolder(oldValuesFormatString);

            if (columnData.Column.Nullable)
            {
                commandText.Append("((");
                commandText.Append(escapedName);
                commandText.Append(" = ");
                commandText.Append(oldValueParameterPlaceHolder);
                commandText.Append(") OR (");
                commandText.Append(escapedName);
                commandText.Append(" IS NULL AND ");
                commandText.Append(oldValueParameterPlaceHolder);
                commandText.Append(" IS NULL))");
            }
            else
            {
                commandText.Append(escapedName);
                commandText.Append(" = ");
                commandText.Append(oldValueParameterPlaceHolder);
            }
        }
 public SqlDataSourceQuery GetSelectQuery()
 {
     if (!this._asteriskField && (this._fields.Count == 0))
     {
         return null;
     }
     StringBuilder builder = new StringBuilder(0x800);
     builder.Append("SELECT");
     if (this._distinct)
     {
         builder.Append(" DISTINCT");
     }
     if (this._asteriskField)
     {
         builder.Append(" ");
         SqlDataSourceColumnData data = new SqlDataSourceColumnData(this.DesignerDataConnection, null);
         builder.Append(data.SelectName);
     }
     if (this._fields.Count > 0)
     {
         builder.Append(" ");
         bool flag = true;
         foreach (SqlDataSourceColumnData data2 in this.GetEffectiveColumns())
         {
             if (!flag)
             {
                 builder.Append(", ");
             }
             builder.Append(data2.SelectName);
             flag = false;
         }
     }
     builder.Append(" FROM");
     builder.Append(" " + this.GetTableName());
     List<Parameter> list2 = new List<Parameter>();
     if (this._filterClauses.Count > 0)
     {
         builder.Append(" WHERE ");
         if (this._filterClauses.Count > 1)
         {
             builder.Append("(");
         }
         bool flag2 = true;
         foreach (SqlDataSourceFilterClause clause in this._filterClauses)
         {
             if (!flag2)
             {
                 builder.Append(" AND ");
             }
             builder.Append("(" + clause.ToString() + ")");
             flag2 = false;
             if (clause.Parameter != null)
             {
                 list2.Add(clause.Parameter);
             }
         }
         if (this._filterClauses.Count > 1)
         {
             builder.Append(")");
         }
     }
     if (this._orderClauses.Count > 0)
     {
         builder.Append(" ORDER BY ");
         bool flag3 = true;
         foreach (SqlDataSourceOrderClause clause2 in this._orderClauses)
         {
             if (!flag3)
             {
                 builder.Append(", ");
             }
             builder.Append(clause2.ToString());
             flag3 = false;
         }
     }
     return new SqlDataSourceQuery(builder.ToString(), SqlDataSourceCommandType.Text, list2.ToArray());
 }
 private SqlDataSourceFilterClause GetCurrentFilterClause()
 {
     string parameterPlaceholder;
     Parameter parameter;
     OperatorItem selectedItem = this._operatorsComboBox.SelectedItem as OperatorItem;
     if (selectedItem == null)
     {
         return null;
     }
     ColumnItem item2 = this._columnsComboBox.SelectedItem as ColumnItem;
     if (item2 == null)
     {
         return null;
     }
     if (selectedItem.IsBinary)
     {
         ParameterEditor editor = this._sourceComboBox.SelectedItem as ParameterEditor;
         if (editor == null)
         {
             return null;
         }
         parameter = editor.Parameter;
         if (parameter != null)
         {
             SqlDataSourceQuery selectQuery = this._tableQuery.GetSelectQuery();
             StringCollection usedNames = new StringCollection();
             if ((selectQuery != null) && (selectQuery.Parameters != null))
             {
                 foreach (Parameter parameter2 in selectQuery.Parameters)
                 {
                     usedNames.Add(parameter2.Name);
                 }
             }
             SqlDataSourceColumnData data = new SqlDataSourceColumnData(this._tableQuery.DesignerDataConnection, item2.DesignerDataColumn, usedNames);
             parameter.Name = data.WebParameterName;
             if (SqlDataSourceDesigner.IsNewSqlServer2008Type(SqlDataSourceDesigner.GetDbProviderFactory(this._tableQuery.DesignerDataConnection.ProviderName), item2.DesignerDataColumn.DataType))
             {
                 parameter.DbType = item2.DesignerDataColumn.DataType;
                 parameter.Type = TypeCode.Empty;
             }
             else
             {
                 parameter.DbType = DbType.Object;
                 parameter.Type = SqlDataSourceDesigner.ConvertDbTypeToTypeCode(item2.DesignerDataColumn.DataType);
             }
             parameterPlaceholder = data.ParameterPlaceholder;
         }
         else
         {
             parameterPlaceholder = string.Empty;
         }
     }
     else
     {
         parameterPlaceholder = "";
         parameter = null;
     }
     return new SqlDataSourceFilterClause(this._tableQuery.DesignerDataConnection, this._tableQuery.DesignerDataTable, item2.DesignerDataColumn, selectedItem.OperatorFormat, selectedItem.IsBinary, parameterPlaceholder, parameter);
 }
 public string GetTableName()
 {
     return(SqlDataSourceColumnData.EscapeObjectName(this.DesignerDataConnection, this.DesignerDataTable.Name));
 }
        public SqlDataSourceQuery GetSelectQuery()
        {
            if (!this._asteriskField && (this._fields.Count == 0))
            {
                return(null);
            }
            StringBuilder builder = new StringBuilder(0x800);

            builder.Append("SELECT");
            if (this._distinct)
            {
                builder.Append(" DISTINCT");
            }
            if (this._asteriskField)
            {
                builder.Append(" ");
                SqlDataSourceColumnData data = new SqlDataSourceColumnData(this.DesignerDataConnection, null);
                builder.Append(data.SelectName);
            }
            if (this._fields.Count > 0)
            {
                builder.Append(" ");
                bool flag = true;
                foreach (SqlDataSourceColumnData data2 in this.GetEffectiveColumns())
                {
                    if (!flag)
                    {
                        builder.Append(", ");
                    }
                    builder.Append(data2.SelectName);
                    flag = false;
                }
            }
            builder.Append(" FROM");
            builder.Append(" " + this.GetTableName());
            List <Parameter> list2 = new List <Parameter>();

            if (this._filterClauses.Count > 0)
            {
                builder.Append(" WHERE ");
                if (this._filterClauses.Count > 1)
                {
                    builder.Append("(");
                }
                bool flag2 = true;
                foreach (SqlDataSourceFilterClause clause in this._filterClauses)
                {
                    if (!flag2)
                    {
                        builder.Append(" AND ");
                    }
                    builder.Append("(" + clause.ToString() + ")");
                    flag2 = false;
                    if (clause.Parameter != null)
                    {
                        list2.Add(clause.Parameter);
                    }
                }
                if (this._filterClauses.Count > 1)
                {
                    builder.Append(")");
                }
            }
            if (this._orderClauses.Count > 0)
            {
                builder.Append(" ORDER BY ");
                bool flag3 = true;
                foreach (SqlDataSourceOrderClause clause2 in this._orderClauses)
                {
                    if (!flag3)
                    {
                        builder.Append(", ");
                    }
                    builder.Append(clause2.ToString());
                    flag3 = false;
                }
            }
            return(new SqlDataSourceQuery(builder.ToString(), SqlDataSourceCommandType.Text, list2.ToArray()));
        }