/// <summary> /// Execute a DELETE query. /// </summary> /// <param name="tableName">The table in which you wish to DELETE.</param> /// <param name="filter">The expression containing the DELETE filter (i.e. WHERE clause data).</param> /// <returns>A DataTable containing the results.</returns> public DataTable Delete(string tableName, Expression filter) { if (String.IsNullOrEmpty(tableName)) { throw new ArgumentNullException(nameof(tableName)); } if (filter == null) { throw new ArgumentNullException(nameof(filter)); } #region Variables string query = ""; DataTable result; List <Column> tableDetails = DescribeTable(tableName); List <string> columnNames = GetColumnNames(tableName); string primaryKeyColumn = GetPrimaryKeyColumn(tableName); #endregion #region Build-DELETE-Query-and-Submit switch (DbType) { case DbTypes.MsSql: query = MssqlHelper.DeleteQuery(tableName, filter); break; case DbTypes.MySql: query = MysqlHelper.DeleteQuery(tableName, filter); break; case DbTypes.PgSql: query = PgsqlHelper.DeleteQuery(tableName, filter); break; } result = RawQuery(query); #endregion return(result); }
/// <summary> /// Execute a DELETE query. /// </summary> /// <param name="tableName">The table in which you wish to DELETE.</param> /// <param name="filter">The expression containing the DELETE filter (i.e. WHERE clause data).</param> /// <returns>A DataTable containing the results.</returns> public DataTable Delete(string tableName, Expression filter) { if (String.IsNullOrEmpty(tableName)) { throw new ArgumentNullException(nameof(tableName)); } if (filter == null) { throw new ArgumentNullException(nameof(filter)); } #region Variables string query = ""; DataTable result; #endregion #region Build-DELETE-Query-and-Submit switch (_DbType) { case DbTypes.MsSql: query = MssqlHelper.DeleteQuery(tableName, filter); break; case DbTypes.MySql: query = MysqlHelper.DeleteQuery(tableName, filter); break; case DbTypes.PgSql: query = PgsqlHelper.DeleteQuery(tableName, filter); break; } result = Query(query); #endregion return(result); }