Exemple #1
0
        public bool UpdateField(string tableName, Database.TableField pKey, Database.TableField update)
        {
            string command = $"UPDATE {tableName} SET {update.Column.Text} = {update.FormattedValue()} WHERE {pKey.Column.Text} == {pKey.FormattedValue()}";

            this.Db.Open();
            int rowsImpacted = new SqliteCommand(command, this.Db).ExecuteNonQuery();

            this.Db.Close();

            return(rowsImpacted == 1);
        }
Exemple #2
0
        public bool Remove(string tableName, Database.TableField pKey)
        {
            string command = $"DELETE FROM {tableName} WHERE {pKey.Column.Text} == {pKey.FormattedValue()}";

            this.Db.Open();
            int rowsImpacted = new SqliteCommand(command, this.Db).ExecuteNonQuery();

            this.Db.Close();

            return(rowsImpacted == 1);
        }
Exemple #3
0
        // Helpers
        private string BuildGetCommandString(string tableName, Database.Comparison op, Database.TableField?field, Database.TableColumn[] columns)
        {
            StringBuilder command = new StringBuilder();

            if ((columns == null) || (columns.Length == 0))
            {
                command.Append($"SELECT *");
            }
            else
            {
                command.Append($"SELECT {columns[0].Text}");
                for (int i = 1; i < columns.Length; i++)
                {
                    command.Append($", {columns[i].Text}");
                }
            }
            command.Append($" FROM {tableName}");
            if (op != null)
            {
                command.Append($" WHERE {field?.Column.Text} {op} {field?.FormattedValue()}");
            }
            return(command.ToString());
        }