Exemplo n.º 1
0
        public SqliteDataReader Update(SQLStatement sqlStatement)
        {
            if (sqlStatement == null)
            {
                return(null);
            }

            string sql = string.Format(
                "UPDATE {0} SET {1} WHERE {2}"
                , sqlStatement.tableName, sqlStatement.GetUpdateFields(), sqlStatement.GetConditions());

            return(Execute(sql));
        }
Exemplo n.º 2
0
        public SqliteDataReader Delete(SQLStatement sqlStatement)
        {
            if (sqlStatement == null)
            {
                return(null);
            }

            string sql = string.Format(
                "DELETE FROM {0} WHERE {1}"
                , sqlStatement.tableName, sqlStatement.GetConditions());

            return(Execute(sql));
        }
Exemplo n.º 3
0
        public SqliteDataReader Query(SQLStatement sqlStatement)
        {
            if (sqlStatement == null)
            {
                return(null);
            }

            StringBuilder sql = new StringBuilder();

            sql.Append(string.Format(
                           "SELECT {0} FROM {1}"
                           , sqlStatement.GetSelectFields(), sqlStatement.tableName));

            string conditions = sqlStatement.GetConditions();

            if (!string.IsNullOrEmpty(conditions))
            {
                sql.Append(" WHERE ");
                sql.Append(conditions);
            }

            string groupBy = sqlStatement.GetGroupByFields();

            if (!string.IsNullOrEmpty(groupBy))
            {
                sql.Append(" GROUP BY ");
                sql.Append(groupBy);
            }

            string orderBy = sqlStatement.GetOrderByFields();

            if (!string.IsNullOrEmpty(orderBy))
            {
                sql.Append(" ORDER BY ");
                sql.Append(orderBy);
            }

            string limit = sqlStatement.GetLimit();

            if (!string.IsNullOrEmpty(limit))
            {
                sql.Append(" LIMIT ");
                sql.Append(limit);
            }

            return(Execute(sql.ToString()));
        }