示例#1
0
        private void AddSequence(string table, string seqName, IPropertyMap identiProperty)
        {
            if (identiProperty == null)
            {
                return;
            }

            if (identiProperty.KeyType == KeyType.Identity || identiProperty.KeyType == KeyType.TriggerIdentity)
            {
                string sequence = seqName;
                if (string.IsNullOrEmpty(seqName))
                {
                    sequence = "S_" + table;
                }

                SequenceDefinition seq = new SequenceDefinition();
                seq.MaxValue  = 10000000000;//
                seq.MinValue  = 0;
                seq.StartWith = 1;
                seq.Increment = 1;
                seq.Name      = sequence;
                seq.Cache     = 2;

                _provider.AddSequence(seq);

                TriggerDefinition trg = new TriggerDefinition();
                trg.Name = "TRG_" + table;
                //trg.TriggerBody = string.Format(" SELECT {0}.nextval INTO :new.id FROM dual; ", seq.Name);
                trg.TriggerBody = string.Format(" SELECT {0}.nextval INTO :new.{1} FROM dual; ", seq.Name, identiProperty.ColumnName);
                trg.Table       = table;
                trg.OnAfter     = false;
                trg.Type        = TriggerType.Insert;
                _provider.AddTrigger(trg);
            }
        }