Exemple #1
0
		/// <summary>
		/// Build 'UPDATE' command.
		/// </summary>
		/// <param name="command">The 'UPDATE' command.</param>
		/// <returns>The DbCommand.</returns>
		public DbCommand BuildUpdateCommand(APSqlUpdateCommand command)
		{
			if (command == null)
				throw new ArgumentNullException("command");

			return ParseUpdate(command);
		}
Exemple #2
0
 /// <summary>
 /// SQL 'FROM' clause extensions.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="phrases">The 'FROM' phrases.</param>
 /// <returns>The command.</returns>
 public static APSqlUpdateCommand from(this APSqlUpdateCommand command, IEnumerable <APSqlFromPhrase> phrases)
 {
     if (phrases != null)
     {
         command.FromClause = new APSqlFromClause(phrases);
     }
     return(command);
 }
Exemple #3
0
 /// <summary>
 /// SQL 'VALUES' clause extensions.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="phrases">The 'SET' phrases</param>
 /// <returns>The command.</returns>
 public static APSqlUpdateCommand values(this APSqlUpdateCommand command, IEnumerable <APSqlSetPhrase> phrases)
 {
     if (phrases != null)
     {
         command.ValuesClause = new APSqlValuesClause(phrases);
     }
     return(command);
 }
Exemple #4
0
 /// <summary>
 /// SQL 'FROM' clause extensions.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="phrases">The 'FROM' phrases.</param>
 /// <returns>The command.</returns>
 public static APSqlUpdateCommand from(this APSqlUpdateCommand command, params APSqlFromPhrase[] phrases)
 {
     if (phrases != null && phrases.Length != 0)
     {
         command.FromClause = new APSqlFromClause(phrases);
     }
     return(command);
 }
Exemple #5
0
 /// <summary>
 /// SQL 'VALUES' clause extensions.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="phrases">The 'SET' phrases</param>
 /// <returns>The command.</returns>
 public static APSqlUpdateCommand values(this APSqlUpdateCommand command, params APSqlSetPhrase[] phrases)
 {
     if (phrases != null && phrases.Length != 0)
     {
         command.ValuesClause = new APSqlValuesClause(phrases);
     }
     return(command);
 }
Exemple #6
0
        /// <summary>
        /// Build 'UPDATE' command.
        /// </summary>
        /// <param name="command">The 'UPDATE' command.</param>
        /// <returns>The DbCommand.</returns>
        public DbCommand BuildUpdateCommand(APSqlUpdateCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            return(ParseUpdate(command));
        }
Exemple #7
0
 /// <summary>
 /// SQL 'WHERE' phrase extensions.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="joinType">Join type.</param>
 /// <param name="phrases">The 'WHERE' phrases.</param>
 /// <returns>The command.</returns>
 public static APSqlUpdateCommand where (this APSqlUpdateCommand command, APSqlConditionJoinType joinType, params APSqlWherePhrase[] phrases)
 {
     if (phrases != null && phrases.Length != 0)
     {
         command.WhereClause = new APSqlWhereClause(joinType, phrases);
     }
     else
     {
         command.WhereClause = null;
     }
     return(command);
 }
Exemple #8
0
 /// <summary>
 /// SQL 'WHERE' phrase extensions.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="joinType">Join type.</param>
 /// <param name="phrases">The 'WHERE' phrases.</param>
 /// <returns>The command.</returns>
 public static APSqlUpdateCommand where (this APSqlUpdateCommand command, APSqlConditionJoinType joinType, IEnumerable <APSqlWherePhrase> phrases)
 {
     if (phrases != null)
     {
         command.WhereClause = new APSqlWhereClause(joinType, phrases);
     }
     else
     {
         command.WhereClause = null;
     }
     return(command);
 }
Exemple #9
0
        /// <summary>
        /// SQL 'VALUES' clause extensions. Add new 'SET' in clause.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="phrases">The 'SET' phrases.</param>
        /// <returns>The command.</returns>
        public static APSqlUpdateCommand set(this APSqlUpdateCommand command, params APSqlSetPhrase[] phrases)
        {
            if (command.ValuesClause == null || command.ValuesClause.Next == null)
            {
                command.ValuesClause = new APSqlValuesClause(phrases);
            }
            else
            {
                APSqlSetPhrase exist = command.ValuesClause.Last as APSqlSetPhrase;
                exist.SetNext(phrases);
            }

            return(command);
        }
Exemple #10
0
        /// <summary>
        /// SQL 'FROM' clause extensions. Add new 'FROM' in clause.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="phrases">The 'FROM' phrases.</param>
        /// <returns>The command.</returns>
        public static APSqlUpdateCommand from_add(this APSqlUpdateCommand command, IEnumerable <APSqlFromPhrase> phrases)
        {
            if (command.FromClause == null || command.FromClause.Next == null)
            {
                command.FromClause = new APSqlFromClause(phrases);
            }
            else
            {
                APSqlFromPhrase exist = command.FromClause.Last as APSqlFromPhrase;
                exist.SetNext(phrases);
            }

            return(command);
        }
Exemple #11
0
        protected override DbCommand ParseUpdate(APSqlUpdateCommand command)
        {
            StringBuilder sb    = new StringBuilder();
            OracleCommand dbCmd = new OracleCommand();

            using (ParserWriter writer = new ParserWriter(sb, command.CommandNameSuitable))
            {
                WriteUpdate(writer, command);
                writer.Idented++;
                WriteSet(writer, command.ValuesClause, dbCmd);
                WriteFrom(writer, command.FromClause, dbCmd);
                WriteWhere(writer, command.WhereClause, dbCmd);
            }

            dbCmd.CommandText = sb.ToString();
            return(dbCmd);
        }
Exemple #12
0
        /// <summary>
        /// SQL 'WHERE' phrase extensions. Add new condition join 'OR' with exist condition.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="phrase">The new 'WHERE' phrase.</param>
        /// <returns>The command.</returns>
        public static APSqlUpdateCommand where_or(this APSqlUpdateCommand command, APSqlWherePhrase phrase)
        {
            if (command.WhereClause == null || command.WhereClause.Next == null)
            {
                command.WhereClause = new APSqlWhereClause(phrase);
            }
            else
            {
                APSqlWherePhrase exist = command.WhereClause.Next as APSqlWherePhrase;
                if (exist is APSqlConditionOrPhrase)
                {
                    (exist as APSqlConditionOrPhrase).Child.Last.SetNext(phrase);
                }
                else
                {
                    command.WhereClause = new APSqlWhereClause(APSqlConditionJoinType.OR, exist, phrase);
                }
            }

            return(command);
        }
Exemple #13
0
 /// <summary>
 /// SQL 'VALUES' clause extensions. Add new 'SET' in clause.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="assignmentExpr">SQL assignment Expression.</param>
 /// <param name="value">Value.</param>
 /// <param name="paramName">Parameter name.</param>
 /// <returns>The command.</returns>
 public static APSqlUpdateCommand set(this APSqlUpdateCommand command, APSqlColumnExpr assignmentExpr, object value, string paramName)
 {
     return(set(command, new APSqlSetPhrase(assignmentExpr, value, paramName)));
 }
Exemple #14
0
 /// <summary>
 /// SQL 'VALUES' clause extensions.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="clause">The 'VALUES' clause.</param>
 /// <returns>The command.</returns>
 public static APSqlUpdateCommand values(this APSqlUpdateCommand command, APSqlValuesClause clause)
 {
     command.ValuesClause = clause;
     return(command);
 }
Exemple #15
0
		/// <summary>
		/// Parse 'UPDATE' command.
		/// </summary>
		/// <param name="command">The 'UPDATE' command.</param>
		/// <returns>The DbCommand.</returns>
		protected abstract DbCommand ParseUpdate(APSqlUpdateCommand command);
		protected override DbCommand ParseUpdate(APSqlUpdateCommand command)
		{
			StringBuilder sb = new StringBuilder();
			SqlCommand dbCmd = new SqlCommand();

			using (ParserWriter writer = new ParserWriter(sb, command.CommandNameSuitable))
			{
				WriteUpdate(writer, command);
				writer.Idented++;
				WriteSet(writer, command.ValuesClause, dbCmd);
				WriteFrom(writer, command.FromClause, dbCmd);
				WriteWhere(writer, command.WhereClause, dbCmd);
			}

			dbCmd.CommandText = sb.ToString();
			return dbCmd;
		}
Exemple #17
0
 private void WriteUpdate(ParserWriter writer, APSqlUpdateCommand command)
 {
     writer.WriteDirect("UPDATE");
     writer.Write(command.TableDef.TableName);
 }
Exemple #18
0
 /// <summary>
 /// SQL 'VALUES' clause extensions.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="phrase">The 'SET' phrase</param>
 /// <returns>The command.</returns>
 public static APSqlUpdateCommand values(this APSqlUpdateCommand command, APSqlSetPhrase phrase)
 {
     command.ValuesClause = new APSqlValuesClause(phrase);
     return(command);
 }
		private void WriteUpdate(ParserWriter writer, APSqlUpdateCommand command)
		{
			writer.WriteDirect("UPDATE");
			writer.Write(command.TableDef.TableName);
		}
Exemple #20
0
 /// <summary>
 /// SQL 'FROM' clause extensions.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="clause">The 'FROM' clause.</param>
 /// <returns>The command.</returns>
 public static APSqlUpdateCommand from(this APSqlUpdateCommand command, APSqlFromClause clause)
 {
     command.FromClause = clause;
     return(command);
 }
Exemple #21
0
 /// <summary>
 /// SQL 'VALUES' clause extensions. Add new 'SET' in clause.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="assignmentExpr">SQL assignment Expression.</param>
 /// <param name="valueExpr">SQL value of assignment Expression.</param>
 /// <returns>The command.</returns>
 public static APSqlUpdateCommand set(this APSqlUpdateCommand command, APSqlColumnExpr assignmentExpr, IAPSqlValueExpr valueExpr)
 {
     return(set(command, new APSqlSetPhrase(assignmentExpr, valueExpr)));
 }
Exemple #22
0
 /// <summary>
 /// Parse 'UPDATE' command.
 /// </summary>
 /// <param name="command">The 'UPDATE' command.</param>
 /// <returns>The DbCommand.</returns>
 protected abstract DbCommand ParseUpdate(APSqlUpdateCommand command);
Exemple #23
0
 /// <summary>
 /// Build 'UPDATE' command.
 /// </summary>
 /// <param name="command">The 'UPDATE' command.</param>
 /// <returns>The DbCommand.</returns>
 public abstract DbCommand BuildUpdateCommand(APSqlUpdateCommand command);
Exemple #24
0
 /// <summary>
 /// Build 'UPDATE' command.
 /// </summary>
 /// <param name="command">The 'UPDATE' command.</param>
 /// <returns>The DbCommand.</returns>
 public override DbCommand BuildUpdateCommand(APSqlUpdateCommand command)
 {
     return(_parser.BuildUpdateCommand(command));
 }
Exemple #25
0
 /// <summary>
 /// SQL 'WHERE' clause extensions.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="clause">The 'WHERE' clause.</param>
 /// <returns>The command.</returns>
 public static APSqlUpdateCommand where (this APSqlUpdateCommand command, APSqlWhereClause clause)
 {
     command.WhereClause = clause;
     return(command);
 }
Exemple #26
0
 /// <summary>
 /// SQL 'WHERE' phrase extensions.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="phrase">The 'WHERE' phrase.</param>
 /// <returns>The command.</returns>
 public static APSqlUpdateCommand where (this APSqlUpdateCommand command, APSqlWherePhrase phrase)
 {
     command.WhereClause = new APSqlWhereClause(phrase);
     return(command);
 }
Exemple #27
0
 /// <summary>
 /// Execute.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="db">The database.</param>
 public static void execute(this APSqlUpdateCommand command, APDatabase db)
 {
     db.ExecuteNonQuery(command);
 }
Exemple #28
0
 /// <summary>
 /// SQL 'FROM' clause extensions.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="phrase">The 'FROM' phrase.</param>
 /// <returns>The command.</returns>
 public static APSqlUpdateCommand from(this APSqlUpdateCommand command, APSqlFromPhrase phrase)
 {
     command.FromClause = new APSqlFromClause(phrase);
     return(command);
 }
		/// <summary>
		/// Build 'UPDATE' command.
		/// </summary>
		/// <param name="command">The 'UPDATE' command.</param>
		/// <returns>The DbCommand.</returns>
		public override DbCommand BuildUpdateCommand(APSqlUpdateCommand command)
		{
			return _parser.BuildUpdateCommand(command);
		}
Exemple #30
0
		/// <summary>
		/// Build 'UPDATE' command.
		/// </summary>
		/// <param name="command">The 'UPDATE' command.</param>
		/// <returns>The DbCommand.</returns>
		public abstract DbCommand BuildUpdateCommand(APSqlUpdateCommand command);