示例#1
0
        ///--------------------------------------------------------------------------------
        /// <summary>This loads information from a SQL view.</summary>
        ///
        /// <param name="sqlView">The input sql view.</param>
        ///--------------------------------------------------------------------------------
        public void LoadView(Microsoft.SqlServer.Management.Smo.View sqlView)
        {
            try
            {
                // load the basic view information
                SqlViewName      = sqlView.Name;
                CreateDate       = sqlView.CreateDate;
                DateLastModified = sqlView.DateLastModified;
                Urn   = sqlView.Urn;
                State = sqlView.State.ToString();

                // load information for each property
                foreach (Column loopColumn in sqlView.Columns)
                {
                    if (DebugHelper.DebugAction == DebugAction.Stop)
                    {
                        return;
                    }
                    SqlViewProperty property = new SqlViewProperty();
                    property.SqlViewPropertyID = Guid.NewGuid();
                    property.SqlView           = this;
                    property.LoadViewProperty(loopColumn, sqlView.TextBody);
                    SqlViewPropertyList.Add(property);
                }
            }
            catch (ApplicationAbortException)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method copies changed metadata between the input
        /// instance and the current instance.</summary>
        ///
        /// <param name="inputSqlViewProperty">The sqlviewproperty to get metadata.</param>
        ///--------------------------------------------------------------------------------
        public void CopyChangedMetadata(SqlViewProperty inputSqlViewProperty)
        {
            DbID             = inputSqlViewProperty.DbID;
            SqlViewID        = inputSqlViewProperty.SqlViewID;
            ReferencedTable  = inputSqlViewProperty.ReferencedTable;
            ReferencedColumn = inputSqlViewProperty.ReferencedColumn;
            Urn         = inputSqlViewProperty.Urn;
            State       = inputSqlViewProperty.State;
            Description = inputSqlViewProperty.Description;

            #region protected
            #endregion protected
        }
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds a tag to TagList.</summary>
 ///--------------------------------------------------------------------------------
 public override void AddTag(string tagName)
 {
     if (ReverseInstance == null)
     {
         ReverseInstance = new SqlViewProperty();
         ReverseInstance.TransformDataFromObject(this, null, false);
     }
     base.AddTag(tagName);
     if (ForwardInstance == null)
     {
         ForwardInstance = new SqlViewProperty();
         ForwardInstance.SqlViewPropertyID = SqlViewPropertyID;
     }
     if (ForwardInstance.TagList.Find(t => t.TagName == tagName) == null)
     {
         ForwardInstance.TagList.Add(new Tag(Guid.NewGuid(), tagName));
     }
 }
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether the input instance metadata is
        /// effectively empty.</summary>
        ///
        /// <param name="inputSqlViewProperty">The sqlviewproperty to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsEmptyMetadata(SqlViewProperty inputSqlViewProperty)
        {
            if (inputSqlViewProperty == null)
            {
                return(true);
            }
            if (inputSqlViewProperty.TagList.Count > 0)
            {
                return(false);
            }
            if (DbID != DefaultValue.Int)
            {
                return(false);
            }
            if (SqlViewID != inputSqlViewProperty.SqlViewID)
            {
                return(false);
            }
            if (!String.IsNullOrEmpty(inputSqlViewProperty.ReferencedTable))
            {
                return(false);
            }
            if (!String.IsNullOrEmpty(inputSqlViewProperty.ReferencedColumn))
            {
                return(false);
            }
            if (!String.IsNullOrEmpty(inputSqlViewProperty.Urn))
            {
                return(false);
            }
            if (!String.IsNullOrEmpty(inputSqlViewProperty.State))
            {
                return(false);
            }
            if (!String.IsNullOrEmpty(inputSqlViewProperty.Description))
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether or not any metadata is
        /// different between the input instance and the current instance.</summary>
        ///
        /// <param name="inputSqlViewProperty">The sqlviewproperty to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsIdenticalMetadata(SqlViewProperty inputSqlViewProperty)
        {
            if (DbID.GetInt() != inputSqlViewProperty.DbID.GetInt())
            {
                return(false);
            }
            if (SqlViewID.GetGuid() != inputSqlViewProperty.SqlViewID.GetGuid())
            {
                return(false);
            }
            if (ReferencedTable.GetString() != inputSqlViewProperty.ReferencedTable.GetString())
            {
                return(false);
            }
            if (ReferencedColumn.GetString() != inputSqlViewProperty.ReferencedColumn.GetString())
            {
                return(false);
            }
            if (Urn.GetString() != inputSqlViewProperty.Urn.GetString())
            {
                return(false);
            }
            if (State.GetString() != inputSqlViewProperty.State.GetString())
            {
                return(false);
            }
            if (Description.GetString() != inputSqlViewProperty.Description.GetString())
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }