/// <summary>
		/// Modify an existing Query.
		/// </summary>
        public DefineQueryControl(Query query, SubLayerDescription description) : this()
		{
            QueryProperties = new QueryWindowProperties() { Query = query, SubLayerDescription = description };
		}
		/// <summary>
		/// Applies the changes to the query and closes the dialog.
		/// </summary>
		public void UpdateQuery()
		{
			List<string> fields = new List<string>();
			foreach (FieldWrapper fw in _visibleFields)
				if (fw.Visible)
					fields.Add(fw.Field.Name);

			Query query = QueryProperties.Query;
			if (query == null) // add a new query
			{
				query = new Query(new QueryDescription()
				{
					Name = "New Query",
					Url = QueryProperties.SubLayerDescription.Url,
					RequiresProxy = QueryProperties.SubLayerDescription.RequiresProxy
				});
			}

			query.WhereClause = WhereClauseTextBox.Text;
			query.VisibleFields = fields;
			QueryProperties.Query = query;
            
            if (FeatureLayer != null)
            {
                SetFeatureQuery(query);
            }
            raiseQueryDefined();
		}