Пример #1
0
        public void Execute(ICollection <DatabaseSequence> baseSequences, ICollection <DatabaseSequence> compareSequences)
        {
            //find new sequences (in compare, but not in base)
            foreach (var sequence in compareSequences)
            {
                var name   = sequence.Name;
                var schema = sequence.SchemaOwner;
                var match  = baseSequences.FirstOrDefault(t => t.Name == name && t.SchemaOwner == schema);
                if (match != null)
                {
                    continue;
                }
                CreateResult(ResultType.Add, sequence, "-- NEW SEQUENCE " + sequence.Name + Environment.NewLine +
                             _writer.AddSequence(sequence));
            }

            //find dropped and existing sequence
            foreach (var sequence in baseSequences)
            {
                var name   = sequence.Name;
                var schema = sequence.SchemaOwner;
                var match  = compareSequences.FirstOrDefault(t => t.Name == name && t.SchemaOwner == schema);
                if (match == null)
                {
                    CreateResult(ResultType.Delete, sequence, "-- DROP SEQUENCE " + sequence.Name + Environment.NewLine +
                                 _writer.DropSequence(sequence));
                }

                //we could alter the sequence, but it's rare you'd ever want to do this
            }
        }