public SdbRequest BuildDelete()
        {
            string sql = $"delete from {_fieldQuotes}{_tableName}{_fieldQuotes} ";

            if (_whereBuilder != null)
            {
                sql += WhereBuilder.Build();
            }
            else
            {
                throw new ArgumentException("WHERE condition is mandatory, you can override with 1=1");
            }

            if (_appendSql != null)
            {
                sql += _appendSql;
            }

            SdbRequest dbRequest = SdbRequest.Of(
                SdbRequest.CmdType.Command,
                sql);

            dbRequest.AddParamRange(WhereBuilder.GetParameters());

            return(dbRequest);
        }
        public SdbRequest BuildUpdate(string customFieldsUpdate = "")
        {
            StringBuilder sql = new StringBuilder($"update {_fieldQuotes}{_tableName}{_fieldQuotes} set ");

            if (!string.IsNullOrEmpty(customFieldsUpdate))
            {
                sql.Append(customFieldsUpdate);
            }

            foreach (var kv in _insertUpdateValues)
            {
                sql.Append(_fieldQuotes + kv.Key + _fieldQuotes + "=@" + kv.Key + ",");
            }

            sql.Remove(sql.Length - 1, 1);


            if (_whereBuilder != null)
            {
                sql.Append(WhereBuilder.Build());
            }
            else
            {
                throw new ArgumentException("WHERE condition is mandatory, you can override with 1=1");
            }

            if (_appendSql != null)
            {
                sql.Append(_appendSql);
            }
            SdbRequest dbRequest = SdbRequest.Of(
                SdbRequest.CmdType.Command,
                sql.ToString(),
                null,
                _insertUpdateValues);

            dbRequest.AddParamRange(WhereBuilder.GetParameters());

            return(dbRequest);
        }
        public SdbRequest BuildSelect()
        {
            string sql = "select ";


            if (_selectFields == null)
            {
                //TODO: shouldn't this case be "select * from table" ?
                throw new ArgumentException("You must inform some select fields before building the SQL");
            }

            sql += _fieldQuotes + string.Join($"{_fieldQuotes},{_fieldQuotes}", _selectFields) + _fieldQuotes;
            sql += $" from {_fieldQuotes}{_tableName}{_fieldQuotes}";

            if (_whereBuilder != null)
            {
                sql += WhereBuilder.Build();
            }

            if (!string.IsNullOrEmpty(_orderCriteria))
            {
                sql += " order by " + _orderCriteria;
            }
            if (_appendSql != null)
            {
                sql += _appendSql;
            }
            SdbRequest dbRequest = SdbRequest.Of(
                _isScalar ? SdbRequest.CmdType.SingleResult : SdbRequest.CmdType.Query,
                sql,
                this._selectFields.ToArray()
                );

            if (_whereBuilder != null)
            {
                dbRequest.AddParamRange(WhereBuilder.GetParameters());
            }

            return(dbRequest);
        }