Ejemplo n.º 1
0
        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        /// <exception cref="InvalidQueryException">The generated query is invalid.</exception>
        public override string ToString()
        {
            var values = ColumnValueCollection.GetValues();

            if (values == null || values.Length == 0)
            {
                throw InvalidQueryException.CreateEmptyColumnList();
            }

            var sb = new StringBuilder();

            sb.Append("UPDATE ");
            sb.Append(Settings.EscapeTable(Table));
            sb.Append(" SET ");

            foreach (var kvp in values)
            {
                sb.Append(Settings.EscapeColumn(kvp.Key));
                sb.Append("=");
                sb.Append(kvp.Value);
                sb.Append(",");
            }

            sb.Length--;

            return(sb.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        /// <exception cref="InvalidQueryException">The query is invalid.</exception>
        public override string ToString()
        {
            var sb = new StringBuilder();

            // Parent
            if (Parent != null)
            {
                sb.Append(Parent);
            }

            // Base operator
            sb.Append(" ON DUPLICATE KEY UPDATE ");

            // Sets
            var values = ColumnValueCollectionBuilder.GetValues();

            if (values == null || values.Length == 0)
            {
                throw InvalidQueryException.CreateEmptyColumnList();
            }

            foreach (var kvp in values)
            {
                sb.Append("`");
                sb.Append(kvp.Key);
                sb.Append("`=");
                sb.Append(kvp.Value);
                sb.Append(",");
            }

            sb.Length--;

            return(sb.ToString().Trim());
        }
Ejemplo n.º 3
0
        private void HandleLinqError(ArgumentException argumentException)
        {
            ExTraceGlobals.ReportingWebServiceTracer.TraceError <string>(0L, "LinqException. Message: {0}", argumentException.Message);
            LocalizedException localizedException = new InvalidQueryException(0, argumentException);

            this.TaskContext.WriteError(localizedException, ExchangeErrorCategory.ServerOperation, null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        /// <exception cref="InvalidQueryException">The generated query is invalid.</exception>
        public override string ToString()
        {
            var sb = new StringBuilder();

            // Base operator
            sb.Append("SELECT ");

            if (DistinctValue)
            {
                sb.Append("DISTINCT ");
            }

            // Columns
            if (AllColumnsValue)
            {
                // All columns
                sb.Append("*");
            }
            else
            {
                // Specified columns only
                var values = ColumnCollection.GetValues();
                if (values == null || values.Length == 0)
                {
                    throw InvalidQueryException.CreateEmptyColumnList();
                }

                foreach (var v in values)
                {
                    sb.Append(v);
                    sb.Append(",");
                }

                sb.Length--;
            }

            // From table
            sb.Append(" FROM ");

            if (Alias != null)
            {
                sb.Append(Settings.ApplyTableAlias(Settings.EscapeTable(Table), Alias));
            }
            else
            {
                sb.Append(Settings.EscapeTable(Table));
            }

            // Joins
            foreach (var j in Joins)
            {
                sb.Append(" ");
                sb.Append(j);
            }

            return(sb.ToString());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        /// <exception cref="InvalidQueryException">The query is invalid.</exception>
        public override string ToString()
        {
            var values = ColumnValueCollection.GetValues();

            if (values == null || values.Length == 0)
            {
                throw InvalidQueryException.CreateEmptyColumnList();
            }

            var sb = new StringBuilder();

            // Base function
            sb.Append("INSERT ");

            if (IgnoreExistsValue)
            {
                sb.Append("IGNORE ");
            }

            sb.Append("INTO ");
            sb.Append(Settings.EscapeTable(Table));

            // Columns
            sb.Append(" (");

            foreach (var kvp in values)
            {
                sb.Append("`");
                sb.Append(kvp.Key);
                sb.Append("`,");
            }

            sb.Length--;

            // Values
            sb.Append(") VALUES (");

            foreach (var kvp in values)
            {
                sb.Append(kvp.Value);
                sb.Append(",");
            }

            sb.Length--;
            sb.Append(") ");

            return(sb.ToString().Trim());
        }