ForumSurfer.Data.Feed.Delete C# (CSharp) Method

Delete() public method

public Delete ( ) : void
return void
        public void Delete()
        {
            String sqlDeleteHosts = @"
                DELETE
                FROM Hosts
                WHERE host_id NOT IN (
                    SELECT host_id
                    FROM Feeds
                );
            ";

            String sqlDeleteArticles = @"
                DELETE
                FROM Articles
                WHERE feed_id = (
                    SELECT feed_id
                    FROM Feeds
                    WHERE uri = $uri
                );
            ";

            String sqlDeleteFeed = @"
                DELETE
                FROM Feeds
                WHERE uri = $uri
            ";

            using (SQLiteConnection m_dbConnection = new SQLiteConnection(Repository.ConnectionString))
            {
                m_dbConnection.Open();
                SQLiteTransaction tran = m_dbConnection.BeginTransaction();
                try
                {
                    SQLiteCommand command = new SQLiteCommand(sqlDeleteArticles, m_dbConnection);
                    command.Parameters.AddWithValue("$uri", Location);
                    command.ExecuteNonQuery();

                    command = new SQLiteCommand(sqlDeleteFeed, m_dbConnection);
                    command.Parameters.AddWithValue("$uri", Location);
                    command.ExecuteNonQuery();

                    command = new SQLiteCommand(sqlDeleteHosts, m_dbConnection);
                    command.ExecuteNonQuery();

                    tran.Commit();
                }
                catch (Exception)
                {
                    tran.Rollback();
                    throw;
                }
            }
        }