Ejemplo n.º 1
0
        /// <summary>
        /// Creates a list of ObjectUpdate objects that are present in the incoming "master list" that are not present in the target database and server.
        /// i.e. Finds the "new objects" that are in the package
        /// </summary>
        /// <param name="masterList">A list of scriptable objects that are found in the base package</param>
        /// <param name="connData">The connection data used for the intial package</param>
        /// <param name="newServer">The database server name that we are going to check for the presence of these scriptable objects</param>
        /// <param name="newDatabase">The database name that we are going to check for the presence of these scriptable objects</param>
        /// <returns>A List of Objects that are in the master list, but not in the target database (i.e. are "new" objects)</returns>
        public static List <SqlBuild.Objects.ObjectUpdates> GetObjectsNotPresentTargetDatabase(List <SqlBuild.Objects.ObjectUpdates> masterList, ConnectionData connData, string newServer, string newDatabase)
        {
            List <SqlBuild.Objects.ObjectUpdates> notPresent = new List <SqlBuild.Objects.ObjectUpdates>();
            ConnectionData tmp = new ConnectionData();

            tmp.Fill(connData);
            tmp.DatabaseName  = newDatabase;
            tmp.SQLServerName = newServer;

            List <ObjectData> lstAllScriptAble = new List <ObjectData>();

            lstAllScriptAble.AddRange(InfoHelper.GetStoredProcedureList(tmp));
            lstAllScriptAble.AddRange(InfoHelper.GetViewList(tmp));
            lstAllScriptAble.AddRange(InfoHelper.GetFunctionList(tmp));
            lstAllScriptAble.AddRange(InfoHelper.GetTriggerObjectList(tmp));

            var x = from m in masterList
                    where
                    !(from s in lstAllScriptAble select s.SchemaOwner + "." + s.ObjectName).Contains(m.SourceObject)
                    select m;

            return(x.ToList());
        }