Deveel.Data.Sql.Sequences.SequenceManager.UpdateSequenceState C# (CSharp) Method

UpdateSequenceState() private method

Updates the state of the sequence key in the sequence tables in the database.
The update occurs on an independent transaction.
private UpdateSequenceState ( Sequence sequence ) : void
sequence Sequence
return void
        private void UpdateSequenceState(Sequence sequence)
        {
            // We need to update the sequence key state.

            // The sequence table
            var seq = Transaction.GetMutableTable(SequenceTableName);

            // Find the row with the id for this sequence.
            var list = seq.SelectRowsEqual(0, Field.Number(sequence.Id)).ToList();

            // Checks
            var count = list.Count();
            if (count == 0)
                throw new ObjectNotFoundException(sequence.FullName);

            if (count > 1)
                throw new Exception("Assert failed: multiple id for sequence.");

            // Create the DataRow
            var dataRow = seq.GetRow(list.First());

            // Set the content of the row data
            dataRow.SetValue(0, Field.Number(sequence.Id));
            dataRow.SetValue(1, Field.Number(sequence.LastValue));
            dataRow.SetValue(2, Field.Number(sequence.SequenceInfo.Increment));
            dataRow.SetValue(3, Field.Number(sequence.SequenceInfo.MinValue));
            dataRow.SetValue(4, Field.Number(sequence.SequenceInfo.MaxValue));
            dataRow.SetValue(5, Field.Number(sequence.SequenceInfo.StartValue));
            dataRow.SetValue(6, Field.BigInt(sequence.SequenceInfo.Cache));
            dataRow.SetValue(7, Field.Boolean(sequence.SequenceInfo.Cycle));

            // Update the row
            seq.UpdateRow(dataRow);
        }