Beispiel #1
0
		/// <summary>
		/// Build 'DELETE' command.
		/// </summary>
		/// <param name="command">The 'DELETE' command.</param>
		/// <returns>The DbCommand.</returns>
		public DbCommand BuildDeleteCommand(APSqlDeleteCommand command)
		{
			if (command == null)
				throw new ArgumentNullException("command");

			return ParseDelete(command);
		}
Beispiel #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 APSqlDeleteCommand from(this APSqlDeleteCommand command, params APSqlFromPhrase[] phrases)
 {
     if (phrases != null && phrases.Length != 0)
     {
         command.FromClause = new APSqlFromClause(phrases);
     }
     return(command);
 }
Beispiel #3
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 APSqlDeleteCommand from(this APSqlDeleteCommand command, IEnumerable <APSqlFromPhrase> phrases)
 {
     if (phrases != null)
     {
         command.FromClause = new APSqlFromClause(phrases);
     }
     return(command);
 }
Beispiel #4
0
        /// <summary>
        /// Build 'DELETE' command.
        /// </summary>
        /// <param name="command">The 'DELETE' command.</param>
        /// <returns>The DbCommand.</returns>
        public DbCommand BuildDeleteCommand(APSqlDeleteCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            return(ParseDelete(command));
        }
Beispiel #5
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 APSqlDeleteCommand where (this APSqlDeleteCommand command, APSqlConditionJoinType joinType, params APSqlWherePhrase[] phrases)
 {
     if (phrases != null && phrases.Length != 0)
     {
         command.WhereClause = new APSqlWhereClause(joinType, phrases);
     }
     else
     {
         command.WhereClause = null;
     }
     return(command);
 }
Beispiel #6
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 APSqlDeleteCommand where (this APSqlDeleteCommand command, APSqlConditionJoinType joinType, IEnumerable <APSqlWherePhrase> phrases)
 {
     if (phrases != null)
     {
         command.WhereClause = new APSqlWhereClause(joinType, phrases);
     }
     else
     {
         command.WhereClause = null;
     }
     return(command);
 }
Beispiel #7
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 APSqlDeleteCommand from_add(this APSqlDeleteCommand command, params 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);
        }
Beispiel #8
0
        protected override DbCommand ParseDelete(APSqlDeleteCommand command)
        {
            StringBuilder sb    = new StringBuilder();
            OracleCommand dbCmd = new OracleCommand();

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

            dbCmd.CommandText = sb.ToString();
            return(dbCmd);
        }
Beispiel #9
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 APSqlDeleteCommand where_or(this APSqlDeleteCommand 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);
        }
Beispiel #10
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 APSqlDeleteCommand from(this APSqlDeleteCommand command, APSqlFromClause clause)
 {
     command.FromClause = clause;
     return(command);
 }
Beispiel #11
0
 /// <summary>
 /// Parse 'DELETE' command.
 /// </summary>
 /// <param name="command">The 'DELETE' command.</param>
 /// <returns>The DbCommand.</returns>
 protected abstract DbCommand ParseDelete(APSqlDeleteCommand command);
Beispiel #12
0
		private void WriteDelete(ParserWriter writer, APSqlDeleteCommand command)
		{
			writer.WriteDirect("DELETE FROM");
			writer.Write(command.TableDef.TableName);
		}
Beispiel #13
0
		protected override DbCommand ParseDelete(APSqlDeleteCommand command)
		{
			StringBuilder sb = new StringBuilder();
			SqlCommand dbCmd = new SqlCommand();

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

			dbCmd.CommandText = sb.ToString();
			return dbCmd;
		}
Beispiel #14
0
 /// <summary>
 /// Execute.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="db">The database.</param>
 public static void execute(this APSqlDeleteCommand command, APDatabase db)
 {
     db.ExecuteNonQuery(command);
 }
Beispiel #15
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 APSqlDeleteCommand from(this APSqlDeleteCommand command, APSqlFromPhrase phrase)
 {
     command.FromClause = new APSqlFromClause(phrase);
     return(command);
 }
Beispiel #16
0
 /// <summary>
 /// Build 'DELETE' command.
 /// </summary>
 /// <param name="command">The 'DELETE' command.</param>
 /// <returns>The DbCommand.</returns>
 public abstract DbCommand BuildDeleteCommand(APSqlDeleteCommand command);
Beispiel #17
0
 /// <summary>
 /// Build 'DELETE' command.
 /// </summary>
 /// <param name="command">The 'DELETE' command.</param>
 /// <returns>The DbCommand.</returns>
 public override DbCommand BuildDeleteCommand(APSqlDeleteCommand command)
 {
     return(_parser.BuildDeleteCommand(command));
 }
Beispiel #18
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 APSqlDeleteCommand where (this APSqlDeleteCommand command, APSqlWherePhrase phrase)
 {
     command.WhereClause = new APSqlWhereClause(phrase);
     return(command);
 }
Beispiel #19
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 APSqlDeleteCommand where (this APSqlDeleteCommand command, APSqlWhereClause clause)
 {
     command.WhereClause = clause;
     return(command);
 }
Beispiel #20
0
 private void WriteDelete(ParserWriter writer, APSqlDeleteCommand command)
 {
     writer.WriteDirect("DELETE FROM");
     writer.Write(command.TableDef.TableName);
 }
Beispiel #21
0
		/// <summary>
		/// Parse 'DELETE' command.
		/// </summary>
		/// <param name="command">The 'DELETE' command.</param>
		/// <returns>The DbCommand.</returns>
		protected abstract DbCommand ParseDelete(APSqlDeleteCommand command);
Beispiel #22
0
		/// <summary>
		/// Build 'DELETE' command.
		/// </summary>
		/// <param name="command">The 'DELETE' command.</param>
		/// <returns>The DbCommand.</returns>
		public override DbCommand BuildDeleteCommand(APSqlDeleteCommand command)
		{
			return _parser.BuildDeleteCommand(command);
		}
Beispiel #23
0
		/// <summary>
		/// Build 'DELETE' command.
		/// </summary>
		/// <param name="command">The 'DELETE' command.</param>
		/// <returns>The DbCommand.</returns>
		public abstract DbCommand BuildDeleteCommand(APSqlDeleteCommand command);