Пример #1
0
        private void PopulateMissingHashes <T>(DynamoMetadataType table, List <T> items)
        {
            var autoIncr = table.Fields.FirstOrDefault(x => x.IsAutoIncrement);

            if (autoIncr != null)
            {
                var seqRequiredPos = new List <int>();
                for (int i = 0; i < items.Count; i++)
                {
                    var item  = items[i];
                    var value = autoIncr.GetValue(item);
                    if (DynamoConverters.IsNumberDefault(value))
                    {
                        seqRequiredPos.Add(i);
                    }
                }
                if (seqRequiredPos.Count == 0)
                {
                    return;
                }

                var nextSequences = Sequences.GetNextSequences(table, seqRequiredPos.Count);
                for (int i = 0; i < nextSequences.Length; i++)
                {
                    var pos = seqRequiredPos[i];
                    autoIncr.SetValue(items[pos], nextSequences[i]);
                }
            }
        }