/// <summary>
        /// Initializes a new instance of the <see cref="ClubCloudServiceApplication"/> class. Use this constructor when creating a new Service Application (e.g. from code in your Create page)
        /// </summary>
        /// <param name="name">The name of the service application.</param>
        /// <param name="service">The <see cref="ClubCloudService" />.</param>
        /// <param name="customDatabase">A custom database to associate with this service application.</param>
        /// <param name="applicationPool">The application pool.</param>
        internal ClubCloudServiceApplication(string name, ClubCloudService service, ClubCloudDatabase customDatabase, SPIisWebServiceApplicationPool applicationPool)
            : base(name, service, applicationPool)
        {
            if (customDatabase == null)
            {
                throw new ArgumentNullException("customDatabase");
            }

            this.database = customDatabase;
        }
        /// <summary>
        /// Deletes the Service Application from the Persisted Object Store. Use this to delete child objects such as custom
        /// databases or Timer Jobs.
        /// </summary>
        public override void Delete()
        {
            // Delete this parent object first, otherwise we can't delete dependent objects like a Database later.
            base.Delete();

            if (this.database != null)
            {
                this.database.Delete();
                this.database = null;
            }
        }