Amazon.DynamoDBv2.DocumentModel.Table.LoadTableInfo C# (CSharp) Метод

LoadTableInfo() приватный Метод

private LoadTableInfo ( ) : void
Результат void
        private void LoadTableInfo()
        {
            ClearTableData();

            bool staleCacheData;
            TableDescription table = TableInfoCache.GetValue(TableName, this.DescribeTable, out staleCacheData);
            this.ContainsCachedData = staleCacheData;
            if (this.ContainsCachedData)
                LoggerInstance.InfoFormat("Description for table [{0}] loaded from SDK Cache", TableName);

            foreach (var key in table.KeySchema)
            {
                string keyName = key.AttributeName;
                AttributeDefinition attributeDefinition = table.AttributeDefinitions
                    .FirstOrDefault(a => string.Equals(a.AttributeName, keyName, StringComparison.Ordinal));
                if (attributeDefinition == null) throw new InvalidOperationException("No attribute definition found for key " + key.AttributeName);
                KeyDescription keyDescription = new KeyDescription
                {
                    IsHash = string.Equals(key.KeyType, "HASH", StringComparison.OrdinalIgnoreCase),
                    Type = GetType(attributeDefinition.AttributeType)
                };
                if (keyDescription.IsHash)
                    HashKeys.Add(keyName);
                else
                    RangeKeys.Add(keyName);
                Keys[keyName] = keyDescription;
            }

            if (table.LocalSecondaryIndexes != null)
            {
                foreach (var index in table.LocalSecondaryIndexes)
                {
                    LocalSecondaryIndexes[index.IndexName] = index;
                    LocalSecondaryIndexNames.Add(index.IndexName);
                }
            }

            if (table.GlobalSecondaryIndexes != null)
            {
                foreach (var index in table.GlobalSecondaryIndexes)
                {
                    GlobalSecondaryIndexes[index.IndexName] = index;
                    GlobalSecondaryIndexNames.Add(index.IndexName);
                }
            }

            foreach (var attribute in table.AttributeDefinitions)
            {
                Attributes.Add(attribute);
            }

            KeyNames = Keys.Keys.ToArray();
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Creates a Table object with the specified configuration, using the
        /// passed-in client to load the table definition.
        ///
        /// This method will throw an exception if the table does not exist.
        /// </summary>
        /// <param name="ddbClient">Client to use to access DynamoDB.</param>
        /// <param name="config">Configuration to use for the table.</param>
        /// <returns>Table object representing the specified table.</returns>
        public static Table LoadTable(IAmazonDynamoDB ddbClient, TableConfig config)
        {
            Table table = new Table(ddbClient, config);

            table.LoadTableInfo();
            return(table);
        }
All Usage Examples Of Amazon.DynamoDBv2.DocumentModel.Table::LoadTableInfo