public GetCurrentValue ( ObjectName name ) : SqlNumber | ||
name | ObjectName | |
Результат | SqlNumber |
public SqlNumber GetCurrentValue() { return(manager.GetCurrentValue(FullName)); }
public ITable GetTable(int offset) { var table = transaction.GetTable(SystemSchema.SequenceInfoTableName); int p = 0; int rowIndex = -1; foreach (var row in table) { var seqType = row.GetValue(3); if (seqType.IsEqualTo(OneValue)) { if (p == offset) { rowIndex = row.RowId.RowNumber; break; } p++; } } if (rowIndex == -1) { throw new ArgumentOutOfRangeException("offset"); } var seqId = table.GetValue(rowIndex, 0); var schema = ObjectName.Parse(table.GetValue(rowIndex, 1).Value.ToString()); var name = table.GetValue(rowIndex, 2).Value.ToString(); var tableName = new ObjectName(schema, name); // Find this id in the 'sequence' table var seqTable = transaction.GetTable(SystemSchema.SequenceTableName); var index = seqTable.GetIndex(0); var list = index.SelectEqual(seqId); if (!list.Any()) { throw new Exception("No SEQUENCE table entry for sequence."); } int seqRowI = list.First(); // Generate the DataTableInfo var tableInfo = CreateTableInfo(schema, name); // Last value for this sequence generated by the transaction DataObject lastValue; try { var sequence = manager.GetSequence(tableName); if (sequence == null) { throw new ObjectNotFoundException(tableName); } lastValue = DataObject.Number(sequence.GetCurrentValue()); } catch (Exception) { lastValue = DataObject.BigInt(-1); } // The current value of the sequence generator var currentValue = DataObject.Number(manager.GetCurrentValue(tableName)); // Read the rest of the values from the SEQUENCE table. var topValue = seqTable.GetValue(seqRowI, 1); var incrementBy = seqTable.GetValue(seqRowI, 2); var minValue = seqTable.GetValue(seqRowI, 3); var maxValue = seqTable.GetValue(seqRowI, 4); var start = seqTable.GetValue(seqRowI, 5); var cache = seqTable.GetValue(seqRowI, 6); var cycle = seqTable.GetValue(seqRowI, 7); return(new SequenceTable(transaction.Database.Context, tableInfo) { TopValue = topValue, LastValue = lastValue, CurrentValue = currentValue, Increment = incrementBy, MinValue = minValue, MaxValue = maxValue, Start = start, Cache = cache, Cycle = cycle }); }